<abstract>This specification defines a Jingle application type for establishing direct or mediated XML streams between two entities over any streaming transport. This technology thus enables two entities to establish a trusted connection for end-to-end encryption or for bypassing server limits on large volumes of XMPP traffic.</abstract>
<remark><p>Adjusted text and examples to reflect Jingle-XTLS, Jingle-IBB, and Jingle-S5B; moved stream security to Jingle-XTLS; moved basic stream setup from XEP-0246 to this document; changed examples to use Jingle-IBB as the transport; clarified stream opening and closing as well as session termination.</p></remark>
<remark><p>Initial published version.</p></remark>
</revision>
<revision>
<version>0.0.1</version>
<date>2008-06-13</date>
<initials>psa/jk/dm</initials>
<remark>First draft.</remark>
</revision>
</header>
<section1topic='Introduction'anchor='intro'>
<p>The standard client-server architecture for XMPP communication provides a stable infrastructure for real-time communication. However, there are certain situations in which it is desirable to bypass the standard client-server architecture, including:</p>
<ul>
<li>Two endpoints cannot access an XMPP server</li>
<li>Two endpoints want to enforce end-to-end encryption</li>
<li>Two endpoints want to send a high volume of XMPP traffic but the intermediate servers enforce rate limits</li>
<p>The first situation is addressed by &xep0174;. However, if the endpoints already have client-to-server connections but wish to bypass those connections or leverage those streams for a higher-level application such as end-to-end encryption, it is desirable for the two endpoints to negotiate an end-to-end XML stream. This specification defines methods for doing so, where the application format is an XML stream and the transport method is any direct or mediated streaming transport, such as &xep0261; (mediated), &xep0260; (direct or mediated), or a future ice-tcp Jingle transport (direct or mediated) based on &ice-tcp;.</p>
<p>First, the party that wishes to initiate the stream determines the responder's capabilities (via &xep0030; or &xep0115;). Here we assume that the responder supports a service discovery feature of 'urn:xmpp:jingle:apps:xmlstream:0' &VNOTE; corresponding to the Jingle XML stream functionality defined herein, as well as the 'urn:xmpp:jingle:transports:ibb:0' feature.</p>
<li><p>An application type of "urn:xmpp:jingle:apps:xmlstream:0".</p></li>
<li><p>Options for the streaming transport method, such as In-Band Bytestreams ("IBB") as defined in <cite>XEP-0261</cite> or SOCKS5 Bytestreams ("S5B") as defined in <cite>XEP-0260</cite>.</p></li>
<pclass='box'>Note: It is STRONGLY RECOMMENDED to encrypt all end-to-end XML streams as described in <cite>Jingle-XTLS</cite> (currently located at <<linkurl='http://xmpp.org/extensions/inbox/jingle-xtls.html'>http://xmpp.org/extensions/inbox/jingle-xtls.html</link>>). Those security flows are NOT described here.</p>
<p>In this example, the initiator is <romeo@montague.lit>, the responder is <juliet@capulet.lit>, and the initiation request specifies a transport method of "jingle-ibb" (i.e., <cite>XEP-0261</cite>).</p>
<p>The clients can then begin to exchange XMPP data over the in-band bytestream. Because the transport is an in-band bytestream, the XMPP data is prepared as described in &xep0047; (i.e., Base64-encoded).</p>
<p>First the initiator sends an initial stream header to the responder.</p>
<p>Note: In accordance with &xmppim;, the initial stream header SHOULD include the 'to' and 'from' attributes, which SHOULD specify the full JIDs of the clients. If the initiator supports stream features and the other stream-related aspects of XMPP 1.0 as specified in <cite>RFC 3920</cite>, then it SHOULD include the version='1.0' flag as shown in the previous example.</p>
<p>The responder then sends a response stream header back to the initiator (because this stream header is sent in the other direction, the IBB 'seq' attribute has a value of zero, not 1).</p>
<p>Once the streams are established, either entity then can send XMPP message, presence, and IQ stanzas, with or without 'to' and 'from' addresses.</p>
<p>However, even after the application-level XML stream is terminated, the negotiated Jingle transport (here in-band bytestream) continues and could be re-used. To completely terminate the Jingle session, the terminating party would then also send a Jingle session-terminate message.</p>
<examplecaption="Responder terminates the stream and session"><![CDATA[
<iqfrom='juliet@capulet.lit/balcony'
id='psy617r4'
to='romeo@montague.lit/orchard'
type='set'>
<jinglexmlns='urn:xmpp:jingle:0'
action='session-terminate'
initiator='romeo@montague.lit/orchard'
sid='851ba2'/>
</iq>
]]></example>
<p>The other party then acknowledges the Jingle session-terminate.</p>
<p>An implementations MUST support the Jingle IBB Transport Method (<cite>XEP-0261</cite>) as a dependable method of last resort. An implementation SHOULD support other streaming transport methods as well, such as the Jingle S5B Transport Method (<cite>XEP-0260</cite>).</p>
<p>This specification defines the following XML namespace:</p>
<ul>
<li>urn:xmpp:jingle:apps:xmlstream:0</li>
</ul>
<p>Upon advancement of this specification from a status of Experimental to a status of Draft, the ®ISTRAR; shall add the foregoing namespaces to the registry located at &NAMESPACES;, as described in Section 4 of &xep0053;.</p>