You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

276 lines

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>Last Activity</title>
  10. <abstract>This specification defines an XMPP protocol extension for communicating information about the last activity associated with an XMPP entity. It is typically used by an IM client to retrieve the most recent presence information from an offline contact by sending a last activity request to the server that hosts the account controlled by the contact.</abstract>
  12. <number>0012</number>
  13. <status>Final</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <dependencies>
  17. <spec>XMPP Core</spec>
  18. <spec>XMPP IM</spec>
  19. </dependencies>
  20. <supersedes/>
  21. <supersededby/>
  22. <shortname>iq-last</shortname>
  23. <schemaloc>
  24. <url></url>
  25. </schemaloc>
  26. &jer;
  27. &temas;
  28. &stpeter;
  29. <revision>
  30. <version>2.0</version>
  31. <date>2008-11-26</date>
  32. <initials>psa</initials>
  33. <remark><p>Per a vote of the XMPP Council, advanced specification to Final; clarified a few small points in the text; added a reference to XEP-0115.</p></remark>
  34. </revision>
  35. <revision>
  36. <version>1.3</version>
  37. <date>2008-07-16</date>
  38. <initials>psa</initials>
  39. <remark><p>Corrected server processing rules to block queries to a full JID when the requesting entity is not authorized to view the presence of the user.</p></remark>
  40. </revision>
  41. <revision>
  42. <version>1.2</version>
  43. <date>2007-02-15</date>
  44. <initials>psa</initials>
  45. <remark><p>Per a vote of the XMPP Council, changed from Historical and Active to Standards Track and Draft; added Implementation Notes and clarified text throughout; added proviso to security considerations regarding client support; added section on Service Discovery.</p></remark>
  46. </revision>
  47. <revision>
  48. <version>1.1</version>
  49. <date>2004-01-22</date>
  50. <initials>psa</initials>
  51. <remark><p>Editorial revisions.</p></remark>
  52. </revision>
  53. <revision>
  54. <version>1.0</version>
  55. <date>2002-01-22</date>
  56. <initials>psa</initials>
  57. <remark><p>Changed status to Active.</p></remark>
  58. </revision>
  59. <revision>
  60. <version>0.3</version>
  61. <date>2002-01-14</date>
  62. <initials>psa</initials>
  63. <remark><p>Made appropriate changes to reflect status as informational.</p></remark>
  64. </revision>
  65. <revision>
  66. <version>0.2</version>
  67. <date>2002-01-04</date>
  68. <initials>tjm</initials>
  69. <remark><p>Converted to XML format.</p></remark>
  70. </revision>
  71. <revision>
  72. <version>0.1</version>
  73. <date>2001-01-25</date>
  74. <initials>jm</initials>
  75. <remark><p>Initial version from website.</p></remark>
  76. </revision>
  77. </header>
  78. <section1 topic='Introduction' anchor='intro'>
  79. <p>It is often helpful to know the time of the last activity associated with a entity. The canonical usage is to discover when a disconnected user last accessed its server. The 'jabber:iq:last' namespace provides a method for retrieving that information. The 'jabber:iq:last' namespace can also be used to discover or publicize when a connected user was last active on the server (i.e., the user's idle time) or to query servers and components about their current uptime.</p>
  80. </section1>
  81. <section1 topic='Protocol' anchor='protocol'>
  82. <p>In order to request last activity information regarding another entity, the requesting entity sends an &IQ; stanza of type "get" to the target entity, containing a &QUERY; element qualified by the 'jabber:iq:last' namespace:</p>
  83. <example caption='Last Activity Query'><![CDATA[
  84. <iq from=''
  85. id='last1'
  86. to=''
  87. type='get'>
  88. <query xmlns='jabber:iq:last'/>
  89. </iq>
  90. ]]></example>
  91. <p>The target entity MUST return either an IQ-result or an IQ-error. When returning an IQ-result, the target entity sends an &IQ; stanza of type='result' containing a &QUERY; element with a REQUIRED 'seconds' attribute and OPTIONAL XML character data.</p>
  92. <example caption='Last Activity Response'><![CDATA[
  93. <iq from=''
  94. id='last1'
  95. to=''
  96. type='result'>
  97. <query xmlns='jabber:iq:last' seconds='903'/>
  98. </iq>
  99. ]]></example>
  100. <p>The requesting entity interprets the IQ-result based on the responding entity's JID type in order to determine the meaning of the information. Specifically, the information means something different depending on the identity of the responding entity:</p>
  101. <ol>
  102. <li>An account registered on an XMPP server, with a JID of the form &LOCALBARE;.</li>
  103. <li>A connected or available resource associated with such an account, with a JID of the form &LOCALFULL;.</li>
  104. <li>An "always-on" XMPP server or service, with a JID of the form &DOMAINBARE;.</li>
  105. </ol>
  106. <p>These differences are explained more fully below.</p>
  107. </section1>
  108. <section1 topic='Offline User Query' anchor='offline'>
  109. <p>The primary usage of the 'jabber:iq:last' namespace is to find out how long ago a user logged out (and, additionally, what their status message was at that time). This primary usage assumes that the IQ-get is sent to a bare JID &LOCALBARE;. When used in this way, the &QUERY; element contained in the IQ-result has a 'seconds' attribute, which is the number of seconds that have passed since the user last logged out. In addition, the element MAY contain XML character data that specifies the status message of the last unavailable presence received from the user. An example is shown below:</p>
  110. <example caption='Last Activity Query'><![CDATA[
  111. <iq from=''
  112. id='last1'
  113. to=''
  114. type='get'>
  115. <query xmlns='jabber:iq:last'/>
  116. </iq>
  117. ]]></example>
  118. <p>As specified in &xmppcore; and &xmppim;, an IQ stanza of type "get" sent to a bare JID &LOCALBARE; is handled by the user's server on the user's behalf, not delivered to one or more connected or available resources.</p>
  119. <p>If the requesting entity is not authorized to view the user's presence information (normally via a presence subscription as defined in <cite>XMPP-IM</cite>), the user's server MUST NOT return last activity information but instead MUST return a &forbidden; error in response to the last activity request.</p>
  120. <example caption='Requesting Entity is Not Authorized to Retrieve Last Activity Information'><![CDATA[
  121. <iq from=''
  122. id='last1'
  123. to=''
  124. type='error'>
  125. <error type='auth'>
  126. <forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  127. </error>
  128. </iq>
  129. ]]></example>
  130. <p>If the requesting entity is authorized to view the user's presence information, the server shall return information about the last presence activity recorded by the server for that user.</p>
  131. <example caption='Last Activity Response by Server'><![CDATA[
  132. <iq from=''
  133. id='last1'
  134. to=''
  135. type='result'>
  136. <query xmlns='jabber:iq:last' seconds='903'>Heading Home</query>
  137. </iq>
  138. ]]></example>
  139. <p>In this example, the user logged out fifteen minutes and three seconds ago, and when they logged out they sent a presence stanza of type='unavailable' whose &lt;status/&gt; element contained the text "Heading Home".</p>
  140. <p>If the user has at least one connected or available resource when the server receives the request, the response MUST (subject to local security policies) contain an empty &lt;query/&gt; element whose 'seconds' attribute is set to a value of '0'.</p>
  141. </section1>
  142. <section1 topic='Online User Query' anchor='online'>
  143. <p>A requesting entity can send a last activity query to the full JID &LOCALFULL; of a connected or available resource associated with an account.</p>
  144. <example caption='Last Activity Query Sent to Full JID'><![CDATA[
  145. <iq from=''
  146. id='last2'
  147. to=''
  148. type='get'>
  149. <query xmlns='jabber:iq:last'/>
  150. </iq>
  151. ]]></example>
  152. <p>In this case, the user's server shall either deliver the IQ to an available resource or respond on behalf of the user.</p>
  153. <p>In particular, as with the offline query use case above, if the requesting entity is not authorized to view the user's presence information (normally via a presence subscription as defined in <cite>XMPP IM</cite>), the user's server MUST NOT deliver the IQ-get to an available resource but instead MUST return a &forbidden; error in response to the last activity request.</p>
  154. <example caption='Requesting Entity is Not Authorized to Retrieve Last Activity Information'><![CDATA[
  155. <iq from=''
  156. id='last1'
  157. to=''
  158. type='error'>
  159. <error type='auth'>
  160. <forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  161. </error>
  162. </iq>
  163. ]]></example>
  164. <p>If the user's server delivers the IQ-get to one of the user's available resources, the user's client MAY respond with the idle time of the user (i.e., the last time that a human user interacted with the client application).</p>
  165. <example caption='Last Activity Response by Client'><![CDATA[
  166. <iq from=''
  167. id='last2'
  168. to=''
  169. type='result'>
  170. <query xmlns='jabber:iq:last' seconds='123'/>
  171. </iq>
  172. ]]></example>
  173. <p>In the foregoing example, the user has been idle for about two minutes.</p>
  174. <p>Support for this functionality is OPTIONAL. A client that does not support the protocol, or that does not wish to divulge this information, MUST return a &unavailable; error.</p>
  175. <example caption='Service Unavailable Error'><![CDATA[
  176. <iq from=''
  177. id='last2'
  178. to=''
  179. type='error'>
  180. <error type='cancel'>
  181. <service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  182. </error>
  183. </iq>
  184. ]]></example>
  185. <p>If there is no available resource matching the &LOCALBARE; in the 'to' attribute of the request, the server MUST follow the rules in <cite>XMPP IM</cite> in order to determine what error stanza to return.</p>
  186. </section1>
  187. <section1 topic='Server and Component Query' anchor='server'>
  188. <p>When the last activity query is sent to a server or component (i.e., to a JID of the form &DOMAINBARE;), the information contained in the IQ reply reflects the uptime of the JID sending the reply. The seconds attribute specifies how long the host has been running since it was last (re-)started. The &QUERY; element SHOULD NOT contain XML character data.</p>
  189. <example caption='Last Activity Query Sent to Server or Service'><![CDATA[
  190. <iq from=''
  191. id='last3'
  192. to=''
  193. type='get'>
  194. <query xmlns='jabber:iq:last'/>
  195. </iq>
  196. ]]></example>
  197. <example caption='Last Activity Response from Server or Service'><![CDATA[
  198. <iq from=''
  199. id='last3'
  200. to=''
  201. type='result'>
  202. <query xmlns='jabber:iq:last' seconds='123456'/>
  203. </iq>
  204. ]]></example>
  205. <p>In this example, the server has been running for a little more than 34 hours.</p>
  206. </section1>
  207. <section1 topic='Determining Support' anchor='support'>
  208. <p>If an entity supports the Last Activity protocol, it MUST advertise that fact in its responses to &xep0030; information ("disco#info") requests by returning a feature of "jabber:iq:last".</p>
  209. <example caption='Requesting entity queries responding entity regarding protocol support'><![CDATA[
  210. <iq from=''
  211. id='disco1'
  212. to=''
  213. type='get'>
  214. <query xmlns=''/>
  215. </iq>
  216. ]]></example>
  217. <example caption='Responding entity communicates protocol support'><![CDATA[
  218. <iq from=''
  219. id='disco1'
  220. to=''
  221. type='result'>
  222. <query xmlns=''>
  223. <feature var='jabber:iq:last'/>
  224. </query>
  225. </iq>
  226. ]]></example>
  227. <p>In order for an application to determine whether an entity supports this protocol, where possible it SHOULD use the dynamic, presence-based profile of service discovery defined in &xep0115;. However, if an application has not received entity capabilities information from an entity, it SHOULD use explicit service discovery instead.</p>
  228. </section1>
  229. <section1 topic='Implementation Notes' anchor='impl'>
  230. <p>The information contained in an IQ reply for this namespace is inherently ambiguous. Specifically, for a bare JID &LOCALBARE; the information is the time since the JID was last connected to its server; for a full JID &LOCALFULL; the information is the time since the resource was last active in the context of an existing session; and for a bare domain the information is the uptime for the server or component. An application MUST take these differences into account when presenting the information to a human user (if any).</p>
  231. </section1>
  232. <section1 topic='Security Considerations' anchor='security'>
  233. <p>A server MUST NOT allow an unauthorized entity to learn a user's network availability by sending a Last Activity request to a JID of the form &LOCALBARE; or &LOCALFULL;, since doing so would constitute a "presence leak" as described in <cite>RFC 6120</cite>. That is, Last Activity information MAY be divulged only to those entities that have permission to view the user's presence via a presence subscription (potentially as restricted by &xep0016; or &xep0191;).</p>
  234. <p>A client MUST provide a way for a human user to disable sending of Last Activity responses from the client's full JID &LOCALFULL;.</p>
  235. </section1>
  236. <section1 topic='IANA Considerations' anchor='iana'>
  237. <p>This document requires no interaction with &IANA;.</p>
  238. </section1>
  239. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  240. <p>No action on the part of the &REGISTRAR; is necessary as a result of this document, since 'jabber:iq:last' is already registered in the protocol namespaces registry located at &NAMESPACES;.</p>
  241. </section1>
  242. <section1 topic='XML Schema' anchor='schema'>
  243. <code><![CDATA[
  244. <?xml version='1.0' encoding='UTF-8'?>
  245. <xs:schema
  246. xmlns:xs=''
  247. targetNamespace='jabber:iq:last'
  248. xmlns='jabber:iq:last'
  249. elementFormDefault='qualified'>
  250. <xs:annotation>
  251. <xs:documentation>
  252. The protocol documented by this schema is defined in
  253. XEP-0012:
  254. </xs:documentation>
  255. </xs:annotation>
  256. <xs:element name='query'>
  257. <xs:complexType>
  258. <xs:simpleContent>
  259. <xs:extension base='xs:string'>
  260. <xs:attribute
  261. name='seconds'
  262. type='xs:unsignedLong'
  263. use='optional'/>
  264. </xs:extension>
  265. </xs:simpleContent>
  266. </xs:complexType>
  267. </xs:element>
  268. </xs:schema>
  269. ]]></code>
  270. </section1>
  271. </xep>