1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-11-18 07:15:07 -05:00
xeps/inbox/sfs.xml

203 lines
13 KiB
XML
Raw Normal View History

<?xml version='1.0' encoding='UTF-8'?>
<!--
Note to editor: Remove xep-file-metadata entity declared below and change all references from &xep-file-metadata; to respective &xepXXXX; to refeence file metadata element when moving to experimental.
-->
<!DOCTYPE xep SYSTEM 'xep.dtd' [
<!ENTITY xep-file-metadata "<span class='ref'><link url='./file-metadata.html'>File metadata element (XEP-xxxx)</link></span> <note>XEP-xxxx: File metadata element &lt;<link url='./file-metadata.html'>https://xmpp.org/extensions/inbox/file-metadata.html</link>&gt;.</note>" >
<!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
<title>Stateless file sharing</title>
<abstract>This specification describes a protocol for stateless asynchronous file sharing with integrity and transport flexibility. It allows clients to provide a good interoperable user experience in combination with Carbons and MAM.</abstract>
&LEGALNOTICE;
<number>xxxx</number>
<status>ProtoXEP</status>
<type>Standards Track</type>
<sig>Standards</sig>
<approver>Council</approver>
<dependencies>
<spec>XMPP Core</spec>
<spec>XEP-0001</spec>
<spec>XEP-xxxx</spec>
</dependencies>
<supersedes/>
<supersededby/>
<shortname>sfs</shortname>
&larma;
<revision>
<version>0.0.1</version>
<date>2020-11-10</date>
<initials>lmw</initials>
<remark><p>First draft.</p></remark>
</revision>
</header>
<section1 topic='Introduction' anchor='intro'>
<p>
This is a reiteration on &xep0385; with some significant changes:
</p>
<ul>
<li>No focus on media, generic for every file type.</li>
<li>No mixed content, body is used for fallback only and not to transmit additional information.</li>
<li>Using &xep-file-metadata;.</li>
<li>Using XML for structured data instead of URIs when possible, adding further extensibility (like providing proper means of sharing encrypted files on http servers).</li>
<li>Not relying on underspecified usage of &xep0372;.</li>
</ul>
</section1>
<section1 topic='Requirements' anchor='reqs'>
<ul>
<li>Do not require any server components for easier deployment</li>
<li>Should work and enable a good UX in multi-user chats like &xep0045; and &xep0369;</li>
<li>Should work great together with conversation synchronization protocols like &xep0280; and &xep0313;</li>
<li>Reuse existing protocols for the actual transport of the data, i.e. &xep0234; or &xep0363;</li>
<li>Guarantee file integrity</li>
<li>Enable aggresive caching</li>
<li>Provide users with metadata, e.g. file size, file type or thumbnail, to help them decide whether or not they want to load the file</li>
<li>Support referring to third party hosting services</li>
<li>Backwards compatibility with existing, widely-deployed protocols</li>
</ul>
</section1>
<section1 topic='Use cases' anchor='usecases'>
<section2 topic='Sharing a file' anchor='file-sharing'>
<p>
To share a file, a user sends a message stanza including <tt>&lt;file-sharing/&gt;</tt> to the inteded recipient contact or group.
The <tt>&lt;file-sharing/&gt;</tt> element includes a <tt>&lt;file/&gt;</tt> metadata element as described in &xep-file-metadata; as well as a <tt>&lt;sources/&gt;</tt> element.
The <tt>&lt;sources/&gt;</tt> element provides one or multiple sources that the receiving client may use to obtain the file.
</p>
<example caption='Sharing summit.jpg with juliet@shakespeare.lit'><![CDATA[
<message to='juliet@shakespeare.lit' from='romeo@montague.lit/resource' id='sharing-a-file'>
<file-sharing xmlns='urn:xmpp:sfs:0'>
<file xmlns='urn:xmpp:file:metadata:0'>
<media-type>image/jpeg</media-type>
<name>summit.jpg</name>
<size>3032449</size>
<dimension>4096x2160</dimension>
<hash xmlns='urn:xmpp:hashes:2' algo='sha3-256'>2XarmwTlNxDAMkvymloX3S5+VbylNrJt/l5QyPa+YoU=</hash>
<hash xmlns='urn:xmpp:hashes:2' algo='id-blake2b256'>2AfMGH8O7UNPTvUVAM9aK13mpCY=</hash>
<desc>Photo from the summit.</desc>
<thumbnail xmlns='urn:xmpp:thumbs:1' uri='cid:sha1+ffd7c8d28e9c5e82afea41f97108c6b4@bob.xmpp.org' media-type='image/png' width='128' height='96'/>
</file>
<sources>
<url-data xmlns='http://jabber.org/protocol/url-data' target='https://download.montague.lit/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/summit.jpg' />
<jinglepub xmlns='urn:xmpp:jinglepub:1' from='romeo@montague.lit/resource' id='9559976B-3FBF-4E7E-B457-2DAA225972BB'>
<description xmlns='urn:xmpp:jingle:apps:file-transfer:5' />
</jinglepub>
</sources>
</file-sharing>
</message>
]]></example>
<p>
It is RECOMMENDED that the file metadata specifies name, media-type, size and one or multiple hash elements as described in &xep0300;.
The hash elements provide end-to-end file integrity and allow efficient caching and flexible retrieval methods.
</p>
<p>
The message MAY include a suitable fallback body.
The fallback body MUST NOT include any information that is not also represented in <tt>&lt;file-sharing/&gt;</tt>.
If the <tt>&lt;sources/&gt;</tt> element includes an <tt>&lt;url-data/&gt;</tt> element that can be represented as a single URL, adding a &xep0066; x-oob reference is RECOMMENDED for compatibility.
</p>
<example caption='Sharing summit.jpg with juliet@shakespeare.lit with fallback'><![CDATA[
<message to='juliet@shakespeare.lit' from='romeo@montague.lit/resource' id='sharing-a-file'>
<file-sharing xmlns='urn:xmpp:sfs:0'>
<!-- ... -->
</file-sharing>
<body>Photo from the summit: https://download.montague.lit/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/summit.jpg</body>
<x xmlns='jabber:x:oob'><url>https://download.montague.lit/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/summit.jpg</url></x>
</message>
]]></example>
<p>If the message has an empty body, it is RECOMMENDED to add a message processing hint, see &xep0334;, to indicate the message to be stored in message stores like &xep0313;.</p>
<example caption='Sharing summit.jpg with juliet@shakespeare.lit without fallback'><![CDATA[
<message to='juliet@shakespeare.lit' from='romeo@montague.lit/resource' id='sharing-a-file'>
<file-sharing xmlns='urn:xmpp:sfs:0'>
<!-- ... -->
</file-sharing>
<store xmlns='urn:xmpp:hints' />
</message>
]]></example>
</section2>
<section2 topic='Receiving a file' anchor='file-receive'>
<p>
On receive of a message including a <tt>&lt;file-sharing/&gt;</tt> element, the receiving entity SHOULD lookup in a local storage, whether the file with any of the proivded hashes has already been retrieved and is available.
In that case no transfer needs to be initated and the cached file can be used instead.
</p>
<p>
If the file is not available locally, the file can be obtained by one of the sources listed in the <tt>&lt;sources/&gt;</tt> element.
If further sources have been attached (as described in <link url="#attach-source">Attaching a source</link>), the receiving entity may also try to obtain the file from any of those.
</p>
<p>
When the source is an <tt>&lt;url-data/&gt;</tt> element as described in &xep0103;, the receiving entity MAY obtain the file by downloading it from the specified URL.
If the URL uses HTTP or HTTPS and additional HTTP request information as specified in &xep0104; is provided, the receiving entity SHOULD use such information when obtaining the file.
When sending and receiving files using <tt>&lt;url-data/&gt;</tt>, it is RECOMMENDED to prefer secure protocols (e.g. HTTPS, FTPS).
Please read <link url="#security">security considerations</link> when implementing support for insecure URLs.
</p>
<p>
When the source is a <tt>&lt;jingle-pub/&gt;</tt> element as described in &xep0358;, the receiving entity MAY obtain the file using the protocol described in &xep0358;.
If a <tt>&lt;hash/&gt;</tt> is provided, the receiving entity MAY obtain the file by requesting it as described in &xep0234;.
</p>
<p>
If sources of any other type are provided, clients MAY attempt to obtain the files from such sources.
The details of obtaining such file are out of scope of this document.
</p>
<p>
If the <tt>&lt;media-type/&gt;</tt> of the shared file is such that it can be displayed inline, the receiving entity MAY display the file inline.
If no <tt>&lt;media-type/&gt;</tt> is provided or the <tt>&lt;media-type/&gt;</tt> indicates that the file can not be displayed inline, i.e. when the media type is <tt>application/octet-stream</tt>, the receiving entity SHOULD NOT display the file inline and instead offer to download it or save it on the users file system.
</p>
</section2>
<section2 topic='Attaching a source' anchor='attach-source'>
<p class='box'>TODO: The following section relies on &xep0367;, however other methods to attach information to another message like the recently proposed &xep0422; might be suitable here as well. This is to be clarified before advancing to Draft.</p>
<p>
After a user shared a file using one entity and another entity in the conversation obtained it or found it in its local storage, that entity MAY announce that the file is now available with an additional source.
This increases availability of the file in case the sender goes offline before all the intended recipients were able to fetch the file. It also allows for peer-to-peer file distribution in group chats.
</p>
<p>
The entity MUST NOT announce itself as an additional source before verifying that <em>all</em> hashes provided match the hash of the file.
If no hashes are provided, the entity SHOULD NOT announce itself as an additional source.
</p>
<p>The attaching itself is performed by sending a message including a <tt>&lt;sources&gt;</tt> element with further sources using the protocol described in &xep0367;.</p>
<p>Depending on the lifetime of the newly attached source, it may be useful to add a message processing hint, see &xep0334;, to indicate the message to be stored in message stores like &xep0313;.</p>
<example caption='romeo@montague.lit/resource2 attaches itself as an additional source for the file'><![CDATA[
<message to='juliet@shakespeare.lit' from='romeo@montague.lit/resource2'>
<attach-to id='sharing-a-file' xmlns='urn:xmpp:message-attaching:1'/>
<sources xmlns='urn:xmpp:sfs:0'>
<jinglepub xmlns='urn:xmpp:jinglepub:1' from='romeo@montague.lit/resource2' id='9559976B-3FBF-4E7E-B457-2DAA225972BB'>
<description xmlns='urn:xmpp:jingle:apps:file-transfer:5' />
</jinglepub>
</sources>
<store xmlns='urn:xmpp:hints' />
</message>
]]></example>
</section2>
</section1>
<section1 topic='Security Considerations' anchor='security'>
<p>
If a <tt>&lt;hash/&gt;</tt> using any supported algorithm is provided, the receiving client SHOULD verify that the <tt>&lt;hash/&gt;</tt> of the announced file matches the obained file before presenting it to the user.
If no <tt>&lt;hash/&gt;</tt> is provided or the <tt>&lt;hash/&gt;</tt> elements provided use unsupported algorithms, receiving clients MUST ignore any attached sources from other senders and only obtain the file from the sources announced by the original sender.
If no <tt>&lt;hash/&gt;</tt> is provided or the <tt>&lt;hash/&gt;</tt> elements provided use unsupported algorithms, receiving clients MUST ignore any sources that use unsecure protocols (e.g. HTTP without TLS).
</p>
<p>
For most methods of transferring a file proposed through the <tt>&lt;sources/&gt;</tt> element, obtaining files requires revealing private information like IP addresses to the sending user or third-parties.
Sources that do not require revealing private information to untrusted entities SHOULD be preferred by receiving entitites.
Receiving entities SHOULD ask users for confirmation before obtaining a file, if doing so would require revealing private information to untrusted entities.
If the protocol that is used when obtaining the file is not secure (e.g. HTTP without TLS), this SHOULD be considered as if the protocol reveals private information.
</p>
<p>
The security considerations of &xep-file-metadata; apply.
</p>
</section1>
<section1 topic='IANA Considerations' anchor='iana'>
<p>This document requires no interaction with &IANA;.</p>
</section1>
<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
<section2 topic='Protocol Namespaces' anchor='ns'>
<p>The &REGISTRAR; includes 'urn:xmpp:sfs:0' in its registry of protocol namespaces (see &NAMESPACES;).</p>
<ul>
<li>urn:xmpp:sfs:0</li>
</ul>
</section2>
</section1>
<section1 topic='Acknowledgements' anchor='ack'>
<p>Thanks to the authors of &xep0385; which heavily inspired this XEP.</p>
</section1>
</xep>