XEP-xxxx: PubSub Namespaces

Abstract
This extension defines a new PubSub node attribute to specify the type of payload.
Authors
  • Timothée Jaussoin
  • Maxime Buquet
Copyright
© 1999 – 2021 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status

ProtoXEP

WARNING: This document has not yet been accepted for consideration or approved in any official manner by the XMPP Standards Foundation, and this document is not yet an XMPP Extension Protocol (XEP). If this document is accepted as a XEP by the XMPP Council, it will be published at <https://xmpp.org/extensions/> and announced on the <standards@xmpp.org> mailing list.
Type
Standards Track
Version
0.0.1 (2021-12-25)
Document Lifecycle
  1. Experimental
  2. Proposed
  3. Stable
  4. Final

1. Introduction

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.

2. Requirements

3. Glossary

PubSub namespace
Identifier used to specify a set of rules and schemas that applies to a specify PubSub node
PubSub service
An entity serving PubSub nodes (e.g., a component, an account with PEP).

4. Discovering Support

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.

Example 1. Service Discovery 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>
Example 2. Service Discovery information response.
<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>

5. Use Cases

5.1 On PubSub Services

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.

5.1.1 Configuring a node with an undefined namespace

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.

Example 3. Error returned when a server isn't capable of finding the corresponding namespace.
<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>

5.1.2 Getting used namespaces from a service

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.

Example 4. Disco result of a service using 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>

5.1.3 Restrict the list of allowed namespaces on a service

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.

Example 5. Disco result from a service configured with an allowed-namespaces list.
<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.

Example 6. disco result from a service configured with an blocked-namespaces list.
<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.

5.2 On PubSub Nodes

5.2.1 Setting the namespace of a node

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).

Example 7. Setting a namespace when creating a node.
<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.

Example 8. Error returned when setting a namespace that isn't in the allowed list.
<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>

5.2.2 Getting the namespace from a node

The node namespace is exposed as urn:xmpp:pubsub-ns:0#namespace in the node metadata (see Discover Node Metadata).

Example 9. Result of a disco#info on a namespaced node
<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>

5.3 Filtering

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.

Example 10. Filtering by namespaces while discovering items on a PubSub service.
<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.

Example 11. Requesting paginated results filtered by namespace.
<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>

6. Security Considerations

TODO

7. IANA Considerations

None.

8. XMPP Registrar Considerations

8.1 PubSub Namespaces Registry

The XMPP Registrar maintains a registry of values for PubSub Namespaces as defined in this XEP. See <https://xmpp.org/registrar/pubsub-namespaces.html>.

8.1.1 Process

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.

9. Design Considerations

People seem not to want to use pubsub#type for this but why?!

10. XML Schema

10.1 urn:xmpp:pubsub-ns:0

<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>

10.2 urn:xmpp:pubsub-ns:errors:0

<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>

Appendices

Appendix A: Document Information

Series
XEP
Number
xxxx
Publisher
XMPP Standards Foundation
Status
ProtoXEP
Type
Standards Track
Version
0.0.1
Last Updated
2021-12-25
Approving Body
XMPP Council
Dependencies
XEP-0004, XEP-0030, XEP-0060
Supersedes
None
Superseded By
None
Short Name
pubsub-ns

This document in other formats: XML  PDF

Appendix B: Author Information

Timothée Jaussoin
Email
edhelas@movim.eu
JabberID
edhelas@movim.eu
Maxime Buquet
Email
pep@bouah.net
JabberID
pep@bouah.net

Copyright

This XMPP Extension Protocol is copyright © 1999 – 2020 by the XMPP Standards Foundation (XSF).

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.

Disclaimer of 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. ##

Limitation of 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.

IPR 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 <https://xmpp.org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).

Visual Presentation

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.

Appendix D: Relation to XMPP

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.

Appendix E: Discussion Venue

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/about/discuss.shtml> for a complete list.

Errata can be sent to <editor@xmpp.org>.

Appendix F: Requirements Conformance

The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".

Appendix G: Notes

Appendix H: Revision History

Note: Older versions of this specification might be available at https://xmpp.org/extensions/attic/

  1. Version 0.0.1 (2021-12-25)

    First draft.

    mb

Appendix I: Bib(La)TeX Entry

@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