The introduction of PubSub brought a lot of new extensions that are now extensively used across the whole XMPP network. However PubSub never specified a way to clearly identify which extension is actually used on a specific node.
This extension defines a new namespace
attribute on a node helping clients and servers implementations to know exactly what kind of data is in a node and how it should be used, i.e., server doing validation, or clients adapting their UI/UX to the type of data.
Having access to this data also enables a new range of features to base on top of this extension, such as filtering, restrictions, etc.
PubSub Namespace introduces a new PubSub Node metadata (as defined in Discover Entity Metadata) called urn:xmpp:pubsub-ns:0#namespace
.
If a server supports the "Pubsub Namespaces" protocol, it MUST advertise the "urn:xmpp:pubsub-ns:0" feature (see Protocol Namespaces regarding issuance of one or more permanent namespaces) in response to a Service Discovery (XEP-0030) information request.
<iq from='hamlet@denmark.lit/elsinore' id='disco1' to='news.capulet.lit' type='get'> <query xmlns='http://jabber.org/protocol/disco#info'/> </iq>
<iq from='news.capulet.lit' id='disco1' to='hamlet@denmark.list/elsinore' type='result'> <query xmlns='http://jabber.org/protocol/disco#info'> … <feature var='urn:xmpp:pubsub-ns:0'/> <feature var='urn:xmpp:pubsub-ns:restrict:0'/> <feature var='urn:xmpp:pubsub-ns:filter:0'/> … </query> </iq>
When a Pubsub service enables Pubsub namespaces all the node creation and configuration on this service MUST have a configured urn:xmpp:pubsub-ns:0#namespace
with the namespace declared in the corresponding specification.
Existing clients and libraries that are not implementing PubSub Namespaces will not provide the urn:xmpp:pubsub-ns:0#namespace
attribute when creating or configuring a PubSub node.
Therefore, if the server supports Pubsub Namespaces and if the client is creating a node where the nodeid is contained in the list of nodes available in the Pubsub Namespaces Registrar, the server MUST then set the corresponding namespace referring to the nodeid.
If a node is created or configured with an empty namespace and the server doesn't find any correspondence in the Registrar, it MUST then return an error of type modify
containing a bad-request
element in the urn:ietf:params:xml:ns:xmpp-stanzas
namespace, alongside a namespace-required
element of namespace urn:xmpp:pubsub-ns:errors:0
.
<iq type='error' from='coven@chat.shakespeare.lit' to='hag66@shakespeare.lit/pda' id='config'> <error type='modify'> <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> <namespace-required xmlns='urn:xmpp:pubsub-ns:errors:0' /> </error> </iq>
Services MUST expose the list of currently used namespaces in the result of a disco#info in a jabber:x:data
form with a FORM_TYPE of value urn:xmpp:pubsub-ns:0
and a used-namespaces
text-multi type field containing the various namespaces.
<iq from='coven@chat.shakespeare.lit' id='disco0' to='hag66@shakespeare.lit/pda' type='result'> <query xmlns='http://jabber.org/protocol/disco#info'> ... <feature var='urn:xmpp:pubsub-ns:0'/> <x xmlns='jabber:x:data' type='result'> <field var='FORM_TYPE' type='hidden'> <value>urn:xmpp:pubsub-ns:0</value> </field> <field type='text-multi' var='used-namespaces' label='Used Namespaces'> <value>urn:xmpp:microblog:0</value> <value>urn:xmpp:bookmark:0</value> <value>urn:xmpp:bookmark:1</value> </field> ... </x> </query> </iq>
The server can define, per service, a list of namespaces to allow or block. The service will then expose the urn:xmpp:pubsub-ns:restrict:0
feature in its disco#info, and return a jabber:x:data
form with a FORM_TYPE of value urn:xmpp:pubsub-ns:0
and an allowed-namespaces
or blocked-namespaces
text-multi type field containing the various namespaces.
The resulting list of blocked or allowed namespaces is available by doing a disco#info on the service.
<iq from='coven@chat.shakespeare.lit' id='disco0' to='hag66@shakespeare.lit/pda' type='result'> <query xmlns='http://jabber.org/protocol/disco#info'> ... <feature var='urn:xmpp:pubsub-ns:0'/> <x xmlns='jabber:x:data' type='result'> <field var='FORM_TYPE' type='hidden'> <value>urn:xmpp:pubsub-ns:0</value> </field> <field type='text-multi' var='allowed-namespaces' label='Allowed Namespaces'> <value>urn:xmpp:microblog:0</value> <value>urn:xmpp:bookmark:0</value> <value>urn:xmpp:bookmark:1</value> </field> ... </x> </query> </iq>
This will be returned alongside used namespaces results, in the same jabber:x:data
form.
<iq from='news.capulet.lit' id='disco1' to='hag66@shakespeare.lit/pda' type='result'> <query xmlns='http://jabber.org/protocol/disco#info'> ... <feature var='urn:xmpp:pubsub-ns:0'/> <x xmlns='jabber:x:data' type='result'> <field var='FORM_TYPE' type='hidden'> <value>urn:xmpp:pubsub-ns:0</value> </field> <field type='text-multi' var='blocked-namespaces' label='Blocked Namespaces'> <value>urn:xmpp:stickers:0</value> <value>urn:xmpp:bookmark:1</value> <value>http://jabber.org/protocol/geoloc</value> </field> ... </x> </query> </iq>
TODO: iq/set interface to service for clients (perms implementation-defined) to set allowed / blocked namespaces? Which would justify the additional disco feature.
When a client sets the namespace of a node, during its creation (Create and Configure a Node), configuration (Configure a Node) or when publishing an item with a publish-options, the server MUST check the filled namespace against the blocked/allowed list defined on the service (See Restrict the list of allowed namespaces on a service).
<iq type='set' from='hamlet@denmark.lit/elsinore' to='news.capulet.lit' id='create'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <create node='foobar'/> <configure> <x xmlns='jabber:x:data' type='submit'> <field var='FORM_TYPE' type='hidden'> <value>http://jabber.org/protocol/pubsub#node_config</value> </field> <field var='urn:xmpp:pubsub-ns:0#namespace'> <value>urn:example:foo:0</value> </field> </x> </configure> </pubsub> </iq>
If the set namespace is forbidden by the service, it MUST return an error of type modify
containing a bad-request
element in the urn:ietf:params:xml:ns:xmpp-stanzas
namespace, alongside a restricted-value
element of namespace urn:xmpp:pubsub-ns:errors:0
.
<iq type='error' from='coven@chat.shakespeare.lit' to='hag66@shakespeare.lit/pda' id='config'> <error type='modify'> <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> <restricted-value xmlns='urn:xmpp:pubsub-ns:errors:0' /> </error> </iq>
The node namespace is exposed as urn:xmpp:pubsub-ns:0#namespace
in the node metadata (see Discover Node Metadata).
<iq type='result' from='coven@chat.shakespeare.lit' to='francisco@denmark.lit/barracks' id='meta'> <query xmlns='http://jabber.org/protocol/disco#info' node='urn:xmpp:microblog:0'> <identity category='pubsub' type='leaf'/> <feature var='http://jabber.org/protocol/pubsub'/> <x xmlns='jabber:x:data' type='result'> <field var='FORM_TYPE' type='hidden'> <value>http://jabber.org/protocol/pubsub#meta-data</value> </field> <field var='urn:xmpp:pubsub-ns:0#namespace' label='Pubsub namespace' type='text-single'> <value>urn:xmpp:microblog:0</value> </field> ... </x> </query> </iq>
While requesting disco#items on a PubSub service, a client might want to only get nodes that are contained in certain namespaces. The client will then add a filter
child of namespace urn:xmpp:pubsub-ns:0
to the query element, containing a jabber:x:data
form with FORM_TYPE of value urn:xmpp:pubsub-ns:0
and an allowed-namespaces
or blocked-namespaces
text-multi type field containing the various namespaces it wants to filter.
In the same way as Restrict the list of allowed namespaces on a service, the blocked-namespaces
value is ignored if both allowed and blocked fields are specified.
<iq type='get' from='hamlet@denmark.lit/elsinore' to='news.capulet.lit'> <query xmlns='http://jabber.org/protocol/disco#items> <filter xmlns='urn:xmpp:pubsub-ns:0'> <x xmlns='jabber:x:data' type='submit'> <field var='FORM_TYPE' type='hidden'> <value>urn:xmpp:pubsub-ns:0</value> </field> <field type='text-multi' var='allowed-namespaces'> <value>urn:xmpp:microblog:0</value> <value>urn:xmpp:bookmark:0</value> <value>urn:xmpp:bookmark:1</value> </field> </x> </filter> </query> </iq>
The server will then return a list of nodes contained in the specified allowed-namespaces
field, or a list of nodes excluding nodes contained in blocked-namespaces
.
Filtering can be combined with XEP-0059 by adding the <set/> element alongside in the query, as a sibling.
<iq type='get' from='hamlet@denmark.lit/elsinore' to='news.capulet.lit' id='disco'> <query xmlns='http://jabber.org/protocol/disco#items'> <filter xmlns='urn:xmpp:pubsub-ns:0'> <x xmlns='jabber:x:data' type='submit'> <field var='FORM_TYPE' type='hidden'> <value>urn:xmpp:pubsub-ns:0</value> </field> <field type='text-multi' var='allowed-namespaces'> <value>urn:xmpp:microblog:0</value> <value>urn:xmpp:bookmark:0</value> <value>urn:xmpp:bookmark:1</value> </field> </x> </filter> <set xmlns='http://jabber.org/protocol/rsm'> <max>20</max> </set> </query> </iq>
TODO
None.
The XMPP Registrar maintains a registry of values for PubSub Namespaces as defined in this XEP. See <https://xmpp.org/registrar/pubsub-namespaces.html>.
In order to submit new values to this registry, the registrant shall define an XML fragment of the following form and either include it in the relevant XMPP Extension Protocol or send it to the email address <registrar@xmpp.org>:
<namespace> <name>the name of the namespace (all lower-case)</name> <desc>a natural-language description of the namespace</desc> <doc>the document (e.g., XEP) in which this namespace is specified</doc> <node>the PubSub node name attached to this namespace (optional)</node> </namespace>
The registrant may register more than one namespace at a time, each contained in a separate <namespace/>
element.
People seem not to want to use pubsub#type
for this but why?!
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:xdata='jabber:x:data' targetNamespace='urn:xmpp:pubsub-ns:0' xmlns='urn:xmpp:pubsub-ns:0' elementFormDefault='qualified'> <xs:annotation> <xs:documentation> The protocol documented by this schema is defined in XEP-XXXX: http://xmpp.org/extensions/xep-xxxx.html </xs:documentation> </xs:annotation> <xs:element name='filter'> <xs:complexType> <xs:choice xmlns:xdata='jabber:x:data'> <xs:element ref='xdata:x'/> </xs:choice> </xs:complexType> </xs:element> </xs:schema>
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:xmpp:pubsub-ns:errors:0' xmlns='urn:xmpp:pubsub-ns:errors:0' elementFormDefault='qualified'> <xs:annotation> <xs:documentation> The protocol documented by this schema is defined in XEP-XXXX: http://xmpp.org/extensions/xep-xxxx.html </xs:documentation> </xs:annotation> <xs:element name='namespace-required' type='empty'/> <xs:element name='restricted-value' type='empty'/> <xs:simpleType name='empty'> <xs:restriction base='xs:string'> <xs:enumeration value=''/> </xs:restriction> </xs:simpleType> </xs:schema>
This document in other formats: XML PDF
This XMPP Extension Protocol is copyright © 1999 – 2024 by the XMPP Standards Foundation (XSF).
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.
## 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. ##
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.
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 <https://xmpp.org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).
The HTML representation (you are looking at) is maintained by the XSF. It is based on the YAML CSS Framework, which is licensed under the terms of the CC-BY-SA 2.0 license.
The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.
The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.
Discussion on other xmpp.org discussion lists might also be appropriate; see <https://xmpp.org/community/> for a complete list.
Errata can be sent to <editor@xmpp.org>.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
Note: Older versions of this specification might be available at https://xmpp.org/extensions/attic/
First draft.
@report{jaussoin2021pubsub-ns, title = {PubSub Namespaces}, author = {Jaussoin, Timothée and Buquet, Maxime}, type = {XEP}, number = {xxxx}, version = {0.0.1}, institution = {XMPP Standards Foundation}, url = {https://xmpp.org/extensions/xep-xxxx.html}, date = {2021-12-25/2021-12-25}, }
END