<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>Private XML Storage</title>
  <abstract>This specification provides canonical documentation of the 'jabber:iq:private' namespace currently in common usage.</abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0049</number>
  <status>Active</status>
  <type>Historical</type>
  <sig>Standards</sig>
  <dependencies>
    <spec>XMPP Core</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>iq-private</shortname>
  <schemaloc>
    <url>http://www.xmpp.org/schemas/iq-private.xsd</url>
  </schemaloc>
  
  <author>
    <firstname>Peter</firstname>
    <surname>Saint-Andre</surname>
    <email>stpeter@stpeter.im</email>
    <jid>stpeter@jabber.org</jid>
    <uri>https://stpeter.im/</uri>
  </author>

  <author>
    <firstname>Russell</firstname>
    <surname>Davis</surname>
    <email>ukscone@burninghorse.com</email>
    <jid>ukscone@burninghorse.com</jid>
  </author>
  <revision>
    <version>1.2</version>
    <date>2004-03-01</date>
    <initials>psa</initials>
    <remark>Corrected several errors in the text; specified security considerations.</remark>
  </revision>
  <revision>
    <version>1.1</version>
    <date>2004-01-06</date>
    <initials>psa</initials>
    <remark>Added XML schema; specified XMPP error handling; added security, IANA, and XMPP Registrar considerations.</remark>
  </revision>
  <revision>
    <version>1.0</version>
    <date>2003-01-09</date>
    <initials>psa</initials>
    <remark>Updated status to Active per vote of the Jabber Council.</remark>
  </revision>
  <revision>
    <version>0.4</version>
    <date>2002-11-21</date>
    <initials>psa</initials>
    <remark>Fixed error handling with regard to reserved namespaces; specified error regarding empty IQ get request.</remark>
  </revision>
  <revision>
    <version>0.3</version>
    <date>2002-11-21</date>
    <initials>psa</initials>
    <remark>Added error scenarios, removed most error codes, cleaned up the text.</remark>
  </revision>
  <revision>
    <version>0.2.1</version>
    <date>2002-10-09</date>
    <initials>rkd</initials>
    <remark>Added error code table.</remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2002-10-08</date>
    <initials>rkd</initials>
    <remark>Corrected author email and jid. Added sentence about the
	inadvisability of use.</remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2002-10-08</date>
    <initials>rkd</initials>
    <remark>Initial version.</remark>
  </revision>
</header>
<section1 topic="Introduction">
  <p>The 'jabber:iq:private' namespace has previously been documented in the Jabber Programmers Guide, but not in a canonical form such as the Internet-Drafts or a XEP. This specification documents the existing usage of jabber:iq:private.</p>
</section1>
<section1 topic="jabber:iq:private Namespace">
  <section2 topic="Description">
    <p>A Jabber client can store any arbitrary XML on the server side by sending an &lt;iq/&gt; stanza of type "set" to the server with a &lt;query/&gt; child scoped by the 'jabber:iq:private' namespace. The &lt;query/&gt; element MAY contain any arbitrary XML fragment as long as the root element of that fragment is scoped by its own namespace. The data can then be retrieved by sending an &lt;iq/&gt; stanza of type "get" with a &lt;query/&gt; child scoped by the 'jabber:iq:private' namespace, which in turn contains a child element scoped by the namespace used for storage of that fragment. Using this method, Jabber entities can store private data on the server and retrieve it whenever necessary. The data stored might be anything, as long as it is valid XML. One typical usage for this namespace is the server-side storage of client-specific preferences; another is <span class="ref"><link url="https://xmpp.org/extensions/xep-0048.html">Bookmark Storage (XEP-0048)</link></span> <note>XEP-0048: Bookmark Storage &lt;<link url="https://xmpp.org/extensions/xep-0048.html">https://xmpp.org/extensions/xep-0048.html</link>&gt;.</note>.</p>
  </section2>
  <section2 topic="Methods">
    <table caption="Description of Acceptable Methods">
      <tr><td>get</td><td>Sent with a blank query to retrieve the private data from the server.</td></tr>
      <tr><td>set</td><td>Sent with the private XML data contained inside of a query.</td></tr>
      <tr><td>result</td><td>Returns the private data from the server.</td></tr>
      <tr><td>error</td><td>There was an error processing the request. The exact error can be found in the child error element.</td></tr>
    </table>
  </section2>
  <section2 topic="Elements">
    <p>The root element of this namespace is query. At least one child element with a proper namespace MUST be included; otherwise the server MUST respond with a "Not Acceptable" error (see <span class="ref"><link url="https://xmpp.org/extensions/xep-0086.html">Error Condition Mappings (XEP-0086)</link></span> <note>XEP-0086: Error Condition Mappings &lt;<link url="https://xmpp.org/extensions/xep-0086.html">https://xmpp.org/extensions/xep-0086.html</link>&gt;.</note> for information about error conditions). A client MUST NOT query for more than one namespace in a single IQ get request. However, an IQ set or result MAY contain multiple elements qualified by the same namespace.</p>

    <example caption="Client Stores Private Data"><![CDATA[
CLIENT:
<iq type="set" id="1001">
  <query xmlns="jabber:iq:private">
    <exodus xmlns="exodus:prefs">
      <defaultnick>Hamlet</defaultnick>
    </exodus>
  </query>
</iq>

SERVER:
<iq type="result"
    from="hamlet@shakespeare.lit/denmark"
    to="hamlet@shakespeare.lit/denmark"
    id="1001"/>
]]></example>

    <example caption="Client Retrieves Private Data"><![CDATA[
CLIENT:
<iq type="get" id="1002">
  <query xmlns="jabber:iq:private">
    <exodus xmlns="exodus:prefs"/>
  </query>
</iq>

SERVER:
<iq type="result"
    from="hamlet@shakespeare.lit/denmark"
    to="hamlet@shakespeare.lit/denmark"
    id="1002">
  <query xmlns="jabber:iq:private">
    <exodus xmlns="exodus:prefs">
      <defaultnick>Hamlet</defaultnick>
    </exodus>
  </query>
</iq>
]]></example>

    <p>If a user attempts to get or set jabber:iq:private data that belongs to another user, the server MUST return a "Forbidden" or "Service Unavailable" error to the sender (the latter condition is in common use by existing implementations, although the former is preferable).</p>
    <example caption="User Attempts to Get or Set Data for Another User"><![CDATA[
CLIENT:
<iq type="set" to="hamlet@shakespeare.lit" id="1003">
  <query xmlns="jabber:iq:private">
    <exodus xmlns="exodus:prefs">
      <defaultnick>Macbeth</defaultnick>
    </exodus>
  </query>
</iq>

SERVER:
<iq type="error"
    from="hamlet@shakespeare.lit"
    to="macbeth@shakespeare.lit"
    id="1003">
  <query xmlns="jabber:iq:private">
    <exodus xmlns="exodus:prefs">
      <defaultnick>Macbeth</defaultnick>
    </exodus>
  </query>
  <error code="403" type="cancel">
    <forbidden
        xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>
]]></example>
    <p>If a user attempts to perform an IQ get without providing a child element, the server SHOULD return a "Bad Format" error (however, some existing implementations return a "Not Acceptable" error in such circumstances):</p>
    <example caption="User Attempts to Get Data Without Specifying Child Element/Namespace"><![CDATA[
CLIENT:
<iq type="set" id="1004">
  <query xmlns="jabber:iq:private"/>
</iq>

SERVER:
<iq type="error" id="1004">
  <query xmlns="jabber:iq:private"/>
  <error code="406" type="modify">
    <bad-format
        xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>
]]></example>
    <p>Certain namespaces are reserved in Jabber (namespaces beginning with 'jabber:' or 'http://jabber.org/', as well as 'vcard-temp'). If a user attempts to get or set jabber:iq:private data in a reserved namespace, historically some server implementations have chosen to return an error (commonly "Not Acceptable") to the sender. Such behavior is OPTIONAL, but may be encountered by clients when interacting with some existing server implementations.</p>
    <example caption="User Attempts to Get or Set Data in a Reserved Namespace"><![CDATA[
CLIENT:
<iq type="set" id="1005">
  <query xmlns="jabber:iq:private">
    <vCard xmlns="vcard-temp">
      <FN>Hamlet</FN>
    </vCard>
  </query>
</iq>

SERVER (optional error):
<iq type="error" id="1005">
  <query xmlns="jabber:iq:private">
    <vCard xmlns="vcard-temp">
      <FN>Hamlet</FN>
    </vCard>
  </query>
  <error code="406" type="modify">
    <not-acceptable
        xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>
]]></example>
  </section2>
</section1>
<section1 topic="Error Conditions">
    <table caption="Error Conditions used by jabber:iq:private">
      <tr><th>Condition</th><th>Description</th></tr>
      <tr><td>Bad Format</td><td>The IQ get does not contain a child element.</td></tr>
      <tr><td>Forbidden</td><td>The IQ get or set is sent to a JID other than that of the sender.</td></tr>
      <tr><td>Not Acceptable</td><td>The IQ get or set is qualified by a reserved namespace.</td></tr>
    </table>
</section1>
<section1 topic="Security Considerations">
  <p>A server MUST NOT allow any entity other than an authorized resource of the user to create, update, or delete private XML stored on behalf of that user.</p>
</section1>
<section1 topic="IANA Considerations">
  <p>This document requires no interaction with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note>.</p>
</section1>
<section1 topic="XMPP Registrar Considerations" anchor="registrar">
  <p>No action on the part of the <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note> is necessary as a result of this document, since 'jabber:iq:private' is already a registered namespace.</p>
</section1>
<section1 topic="XML Schema">
    <code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='jabber:iq:private'
    xmlns='jabber:iq:private'
    elementFormDefault='qualified'>

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

  <xs:element name='query'>
    <xs:complexType>
      <xs:sequence minOccurs='0'>
        <xs:any namespace='##other'/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>
]]></code>
</section1>
</xep>
