1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-11-21 08:45:04 -05:00

Add XEP proposal for Stickers

This commit is contained in:
Marvin W 2020-11-10 20:51:37 +01:00
parent 2b3d45b25f
commit 2cd676e6aa
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A

232
inbox/stickers.xml Normal file
View File

@ -0,0 +1,232 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Note to editor:
- Remove xep-sfs entity declared below and change all references from &xep-sfs; to respective &xepXXXX; to refeence sfs when moving to experimental.
- Remove xep-file-metadata entity declared below and change all references from &xep-file-metadata; to respective &xepXXXX; to refeence file metadata 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 xep-sfs "<span class='ref'><link url='./sfs.html'>Stateless file sharing (XEP-xxxx)</link></span> <note>XEP-xxxx: Stateless file sharing &lt;<link url='./sfs.html'>https://xmpp.org/extensions/inbox/sfs.html</link>&gt;.</note>" >
<!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
<!ENTITY sepl4 "0x1f (ASCII Unit Separator)">
<!ENTITY sepl3 "0x1e (ASCII Record Separator)">
<!ENTITY sepl2 "0x1d (ASCII Group Separator)">
<!ENTITY sepl1 "0x1c (ASCII File Separator)">
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
<title>Stickers</title>
<abstract>This specification provides a protocol to send stickers and to create and share sticker packs.</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>
</dependencies>
<supersedes/>
<supersededby/>
<shortname>stickers</shortname>
&larma;
<revision>
<version>0.0.1</version>
<date>2020-11-03</date>
<initials>lmw</initials>
<remark><p>First draft.</p></remark>
</revision>
</header>
<section1 topic='Introduction' anchor='intro'>
<p>Stickers<note><em>Sticker (messaging)</em> on Wikipedia &lt;<link url='https://en.wikipedia.org/wiki/Sticker_(messaging)'>https://en.wikipedia.org/wiki/Sticker_(messaging)</link>&gt;.</note> are images or short animations that often represent an emoticon or an action. They are increasingly used in private messaging in the last years, especially on mobile phone apps. Stickers can be more nuanced and expressive than emoticons. They can be used to convey emotions or tell stories in a fun and easy way.</p>
<p>Recently, demand to implement stickers, including their social feature of sharing sticker packs arised within the XMPP community. This specification is to fulfill this demand.</p>
</section1>
<section1 topic='Requirements' anchor='reqs'>
<ul>
<li>Do not require additional server components for easier deployment</li>
<li>Compatibility with non-graphical user interfaces (terminals, etc)</li>
</ul>
</section1>
<section1 topic='Glossary' anchor='glossary'>
<dl>
<di><dt>Sticker</dt><dd>Emoticon-like picture</dd></di>
<di><dt>Sticker pack</dt><dd>Collection of stickers, typically devoted to a specific theme or with all stickers created by the same author</dd></di>
</dl>
</section1>
<section1 topic='Use Cases' anchor='usecases'>
<section2 topic='Creating a sticker pack' anchor='create'>
<p>
Sticker packs are stored on pubsub nodes.
They SHOULD be located at a personal eventing (PEP) node named "urn:xmpp:stickers:0" but MAY be located at a generic publish-subscribe node that is not attached to a user's IM account.
The pubsub node's access model SHOULD be set to 'open', so that other users can fetch sticker packs.
</p>
<section3 topic='Sticker pack pubsub item' anchor='pubsub-item'>
<p>
Each sticker pack is one item on the pubsub node consisting of a <tt>&lt;pack/&gt;</tt> element.
</p>
<p>
The <tt>&lt;pack/&gt;</tt> element includes elements <tt>&lt;name/&gt;</tt> and <tt>&lt;summary/&gt;</tt> to announce a name and summary of the sticker pack that can be displayed to users, respectively.
The summary MAY contain copyright and license information in user-readable format.
Multiple <tt>&lt;name/&gt;</tt> and <tt>&lt;summary/&gt;</tt> elements MAY be included given that no two elements of same name specify the same <tt>xml:lang</tt>.
</p>
<p>
The <tt>&lt;pack/&gt;</tt> element MAY include a <tt>&lt;restricted/&gt;</tt> element to indicate that this sticker pack may not be used or imported by other users.
</p>
<p>
The <tt>&lt;pack/&gt;</tt> element contains one or more <tt>&lt;item/&gt;</tt> elements that include details on the stickers in the pack. Each <tt>&lt;item/&gt;</tt> element has <tt>&lt;file/&gt;</tt> element as described in &xep-file-metadata;. The metadata MUST include one or multiple <tt>&lt;hash/&gt;</tt> elements as described in &xep0300;. All stickers in a pack MUST use the same algorithm for their <tt>&lt;hash/&gt;</tt> elements. The metadata MUST include one <tt>&lt;desc/&gt;</tt> element that is not qualified by a <tt>xml:lang</tt> attribute and describes the textual fallback (often an emoji or a sequence of emojis) of the sticker. Each <tt>&lt;item/&gt;</tt> element further has a <tt>&lt;sources/&gt;</tt> element as described in &xep-sfs; describing how to retrieve the image file of the sticker. Each <tt>&lt;item/&gt;</tt> element MAY include one or more <tt>&lt;suggest/&gt;</tt> elements that include a text that clients may replace with the sticker. <tt>&lt;suggest/&gt;</tt> elements MAY have an <tt>xml:lang</tt> attribute.
</p>
<p>
Finally, the <tt>&lt;pack/&gt;</tt> element includes a single <tt>&lt;hash/&gt;</tt> element as described in &xep0300;, specifying the hash of the sticker pack. See <link url='#pack-hash'>next section</link> on how such hash is generated.
</p>
</section3>
<section3 topic='Sticker pack hash calculation' anchor='pack-hash'>
<p>Each sticker pack has a unique ID, which is used as the pubsub item's id. This ID is derived from a hash of significant information from a <tt>&lt;pack/&gt;</tt> element as outlined in this section.</p>
<ol>
<li><p>Processing <tt>&lt;name/&gt;</tt> and <tt>&lt;summary/&gt;</tt> elements:</p>
<ol>
<li><p>For each <tt>&lt;name/&gt;</tt> or <tt>&lt;summary/&gt;</tt> element:</p>
<ol>
<li>Encode the character data of element name (<tt>name</tt> or <tt>summary</tt>), <tt>xml:lang</tt> attribute value and content.</li>
<li>Append an octet of value &sepl4; to each resulting octet string.</li>
<li>Join the resulting octet strings together, in the order of element name, <tt>xml:lang</tt> attribute and content, resulting in a single octet string for the <tt>&lt;name/&gt;</tt> or <tt>&lt;summary/&gt;</tt> element.</li>
<li>Append an octet of value &sepl3;.</li>
</ol>
</li>
<li>Join the resulting octet strings together, ordered from lesser to greater.</li>
<li>Append an octet of value &sepl1;.</li>
</ol>
<p>The result of this step is referenced as <em>Meta string</em> later.</p>
</li>
<li><p>Processing <tt>&lt;item/&gt;</tt> elements:</p>
<ol>
<li><p>For each <tt>&lt;item/&gt;</tt> element:</p>
<ol>
<li>Encode the character data of <tt>&lt;file/&gt;</tt>'s <tt>&lt;desc/&gt;</tt> content.</li>
<li>Append an octet of value &sepl3; to the resulting octet string.</li>
<li><p>For each of <tt>&lt;hash/&gt;</tt> element in <tt>&lt;file/&gt;</tt>:</p>
<ol>
<li>Encode the character data of <tt>algo</tt> attribute and content.</li>
<li>Append an octet of value &sepl4; to the resulting octet strings.</li>
<li>Join the resulting octet strings together, in the order of <tt>algo</tt> attribute and content, resulting in a single octet string for the <tt>&lt;hash/&gt;</tt> element.</li>
<li>Append an octet of value &sepl3;.</li>
</ol>
</li>
<li>Join the resulting octet strings together, in the order of <tt>&lt;file/&gt;</tt>'s <tt>&lt;desc/&gt;</tt> content first and then all <tt>&lt;hash/&gt;</tt> elements ordered from lesser to greater.</li>
<li>Append an octet of value &sepl2;.</li>
</ol>
</li>
<li>Join the resulting octet strings together, ordered from lesser to greater.</li>
<li>Append an octet of value &sepl1;.</li>
</ol>
<p>The result of this step is referenced as <em>Stickers string</em> later.</p>
</li>
<li>Join the <em>Meta String</em> and <em>Stickers String</em> together, in this order.</li>
<li>Hash the resulting string using the algorithm choosen for the sticker pack.</li>
</ol>
<p>The ID of the sticker pack is dervied by taking the first 144 bit of the hash and encode it using Base64. This is equivalent to the first 24 characters of the Base64 encoded content of the <tt>&lt;hash/&gt;</tt> element.</p>
</section3>
<example caption='Publish a new sticker pack'><![CDATA[
<iq from='romeo@montague.lit/pda'
id='pub1'
to='romeo@montague.lit'
type='set'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='urn:xmpp:stickers:0'>
<item id='EpRv28DHHzFrE4zd+xaNpVb4'>
<pack xmlns='urn:xmpp:stickers:0'>
<name>Marsey the Cat</name>
<summary>Be cute or be cynical, this little kitten works both ways.</summary>
<item>
<file xmlns='urn:xmpp:file:metadata:0'>
<media-type>image/png</media-type>
<desc>👍</desc>
<size>71045</size>
<dimension>512x512</dimension>
<hash xmlns='urn:xmpp:hashes:2' algo='sha-256'>0AdP8lJOWJrugSKOIAqfEKqFatIpG5JBCjjxY253ojQ=</hash>
</file>
<sources xmlns='urn:xmpp:sfs:0'>
<url-data xmlns='http://jabber.org/protocol/url-data' target='https://download.montague.lit/51078299-d071-46e1-b6d3-3de4a8ab67d6/sticker_marsey_thumbs_up.png' />
</sources>
<suggest>+1</suggest>
</item>
<item>
<file xmlns='urn:xmpp:file:metadata:0'>
<media-type>image/png</media-type>
<desc>😘</desc>
<size>67016</size>
<dimension>512x512</dimension>
<hash xmlns='urn:xmpp:hashes:2' algo='sha-256'>gw+6xdCgOcvCYSKuQNrXH33lV9NMzuDf/s0huByCDsY=</hash>
</file>
<sources xmlns='urn:xmpp:sfs:0'>
<url-data xmlns='http://jabber.org/protocol/url-data' target='https://download.montague.lit/51078299-d071-46e1-b6d3-3de4a8ab67d6/sticker_marsey_kiss.png' />
</sources>
</item>
<!-- ... -->
<hash xmlns='urn:xmpp:hashes:2' algo='sha-256'>EpRv28DHHzFrE4zd+xaNpVb4jbu4s74XtioExNjQzZ0=</hash>
</pack>
</item>
</publish>
</pubsub>
</iq>
]]></example>
</section2>
<section2 topic='Sending a sticker' anchor='send'>
<p>The sending entity uses &xep-sfs; to send the image file from the sticker pack. The <tt>&lt;item/&gt;</tt>'s <tt>&lt;file/&gt;</tt> and <tt>&lt;sources/&gt;</tt> elements from the sticker pack are used as a template. The sending entity MAY add additional <tt>&lt;hash/&gt;</tt> elements or sources.</p>
<p>Additionally, the sending entity adds an element <tt>&lt;sticker/&gt;</tt> to the message. This element carries an attribute <tt>pack</tt> referring to the id of the pubsub item carrying the sticker pack. If the sticker pack resides on a pubsub item other than the senders personal eventing (PEP) node named "urn:xmpp:stickers:0", the sending entity must add additional attributes <tt>jid</tt> and <tt>node</tt>, referring to the jid of the pubsub node and the name of the node, respectively.</p>
<p>The sending entity SHOULD use the <tt>&lt;file/&gt;</tt>'s <tt>&lt;desc/&gt;</tt> content as the message body, except if the sticker was selected based on a suggestion, in which case the content of the corresponding <tt>&lt;suggest/&gt;</tt> SHOULD be used.</p>
<example caption='Sending a sticker'><![CDATA[
<message to='juliet@shakespeare.lit' from='romeo@montague.lit/pda' id='sharing-a-file'>
<body>😘</body>
<sticker xmlns='urn:xmpp:stickers:0' pack='EpRv28DHHzFrE4zd+xaNpVb4' />
<file-sharing xmlns='urn:xmpp:sfs:0'>
<file xmlns='urn:xmpp:file:metadata:0'>
<media-type>image/png</media-type>
<desc>😘</desc>
<size>67016</size>
<dimension>512x512</dimension>
<hash xmlns='urn:xmpp:hashes:2' algo='sha-256'>gw+6xdCgOcvCYSKuQNrXH33lV9NMzuDf/s0huByCDsY=</hash>
</file>
<sources>
<url-data xmlns='http://jabber.org/protocol/url-data' target='https://download.montague.lit/51078299-d071-46e1-b6d3-3de4a8ab67d6/sticker_marsey_kiss.png' />
</sources>
</file-sharing>
</message>
]]></example>
</section2>
<section2 topic='Receiving a sticker' anchor='receive'>
<p>When receiving a message with a <tt>&lt;sticker/&gt;</tt> element, the receiving entity SHOULD consider the message and the <tt>&lt;file-sharing/&gt;</tt> element as a sticker.</p>
<p>When receiving a sticker, the receiving entity may display the stickers image file inline or display the textual representation in the <tt>&lt;desc/&gt;</tt> element. The receiving entity SHOULD NOT display the received sticker only as a downloadable file.</p>
</section2>
<section2 topic='Importing a sticker pack' anchor='import'>
<p>When receiving a sticker or any other reference to a sticker pack, the receiving entity may allow the user to import such sticker pack. The receiving entity SHOULD NOT offer to import a sticker pack that has a <tt>&lt;restricted/&gt;</tt> element.</p>
<p>When importing a sticker pack, the entity SHOULD make all files that are part of the sticker pack locally available. The entity SHOULD duplicate the pubsub item from its original source to the users personal eventing (PEP) node named "urn:xmpp:stickers:0", preserving the pack id. The entity MAY remove any of the sources provided, and MAY make an effort to make the files available at additional sources, e.g. by using &xep0363;.</p>
</section2>
<section2 topic='Sharing a sticker pack' anchor='share'>
<p>After creating or importing a sticker pack, it can be shared using an <tt>xmpp:</tt>-uri as described in &xep0060;.</p>
<p>When handling this URI, the entity SHOULD display a preview of the sticker pack and allow importing it as described above.</p>
<example caption='Sticker pack URI'>xmpp:romeo@montague.lit?pubsub;action=retrieve;node=urn:xmpp:stickers:0;item=EpRv28DHHzFrE4zd%2BxaNpVb4</example>
</section2>
</section1>
<section1 topic='Accessibility Considerations' anchor='access'>
<p>Flickering, flashing or blinking stickers can induce seizures or other incapacitating physical reactions. It is RECOMMENDED that clients that support stickers have an option to disable animations and/or stickers entirely.</p>
</section1>
<section1 topic='Security Considerations' anchor='security'>
<p>
The security considerations of &xep-sfs; 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:stickers:0' in its registry of protocol namespaces (see &NAMESPACES;).</p>
<ul>
<li>urn:xmpp:stickers:0</li>
</ul>
</section2>
</section1>
</xep>