First draft.
The XMPP ecosystem has no way to allow clients to display or refer the user to the Terms of Service and Privacy Policy of any given server.
The specification shall allow to satisfy the following requirements:
OPTIONAL.
A server which supports the Terms of Service protocol announces support via both stream features and Service Discovery (XEP-0030)
The interaction with the Terms of Service is handled using Ad-Hoc Commands (XEP-0050)
To request the current Terms of Service and Opt-ins/Opt-outs, the client starts an Ad-Hoc command session with the 'urn:xmpp:tos:0' node at its server:
The client MUST include a <tos-support/> child in the initial request to inform the server that it fully supports the protocol. A server MAY reject the Ad-Hoc command from a client which does not fully support the protocol if the form would likely not render correctly or completely. In that case, a <not-acceptable/> type='cancel' error MUST be returned.
The server SHOULD use the value of xml:lang at the <command/> element to determine the language of returned texts.
If the server allows the request, it starts the command session and returns the payload:
The command payload consists of two parts: The data form for legacy clients and additional opt-ins/opt-outs, and the machine-readable Terms of Service data. The machine-readable Terms of Service data is carried by a <tos/> element.
The <tos/> element has the following format:
In the future, more children may be added to the <tos/> element. Conforming clients thus MUST ignore all children they do not understand.
The <document/> element has the following format:
The <required-flags/> element contains zero or more <required-flag/> elements. The <required-flag/> elements have a var attribute which refers to one of the fields in the data form. Note that this is semantically different from <require/> in the data form (see Data Forms (XEP-0004)
The data form has the FORM_TYPE 'urn:xmpp:tos:0'. The fields 'urn:xmpp:tos:0#version' and 'urn:xmpp:tos:0#documents' are mandatory. If the value of the 'urn:xmpp:tos:0#version' data form field and the version attribute of the <tos/> element differ, the response is invalid.
The data form MAY contain arbitrary fields after the 'urn:xmpp:tos:0#documents' field.
A client supporting the Terms of Service protocol should remove the fields prefixed with 'urn:xmpp:tos:0#' from the form when displaying the form and use a richer representation obtained from the <tos/> element for the same data.
The 'urn:xmpp:tos:0#documents' MUST contain exactly one URL from each <document/> advertised in the <tos/> element. It is used to inform users of legacy clients of the terms.
The server MAY include <instruction/> and <title/> elements in the data form.
Once the user has filled out the form, the client submits it to the server:
The client does not include the <tos/> element in its response.
The server acknowledges the reception as usual:
If the client did not include a <tos-support/> element in the initiating request and the server requires support for the Terms of Service protocol, it replies with an error:
The server SHOULD include a human readable error text which MAY include a URL to a website where the user can agree to the terms and manage the opt-ins/opt-outs.
If the user did not opt in into options required by the service, the service returns the original data to the client and adds an error note to the command:
If a server updates its Terms of Service, it may inform its users with a notification. For this, a 'headline' <message/> is used:
The <body/> is included for clients not supporting the protocol. The user can then review the Terms of Service by themselves. In addition to the <body/>, a <tos-push/> element which contains the <tos/> element of the new terms and an optional <deadline/> element.
The <deadline/> element includes a XMPP Date and Time Profiles (XEP-0082)
If a user does not agree to an update of the Terms of Service, a service may lock down the account. In this case, authentication is handled as normal. In the post-authentication stream features, the server then MUST include a <tos/> element with a <agreement-required/> child:
If the <agreement-required/> element is included in the <tos/> stream feature, the client must first agree to the Terms of Service as described in Interact with Terms of Service.
If a client attempts to bind a resource before agreeing to the Terms of Service, the server rejects the request with a <policy-violation/> type 'cancel' error including an application defined condition of <agreement-required> in the namespace of this protocol.
A human readable error MUST be included for legacy clients. The human readable version SHOULD contain a URL to a web page where the user can agree to the Terms of Service without client support.
OPTIONAL.
The service SHOULD honor the xml:lang value of the Ad-Hoc Commands (XEP-0050)
When pushing a notification about a terms of service update, the service SHOULD use the stream-level xml:lang attribute to determine the locale used for the announcement.
This specification allows another type of interaction before authentication. Server implementations MUST ensure that this protocol cannot be abused for pre-authentication attacks (e.g. Denial of Service).
Servers MUST NOT allow entities to query the Terms of Service of another server unless they are authenticated.
REQUIRED.
REQUIRED.
REQUIRED for protocol specifications.