Source: https://xmpp.org/extensions/xep-0401.html
Timestamp: 2019-04-26 05:55:20+00:00

Document:
This document defines a protocol and URI scheme for user invitation in order to allow a third party to register on a server. The goal of this is to make onboarding for XMPP IM newcomers as easy as possible.
Download an XMPP client (if needed).
Optionally register an account with Romeo's server (if permitted by the server rules), or with a public server.
Establish a mutual presence subscription between Romeo and Juliet.
The process is designed to automatically skip steps that Juliet already completed, to make the overall experience as smooth as possible.
Register an account on Romeo's server with a user name defined by Romeo and a password not known to Romeo.
This specification makes use of XMPP URIs. The basic URI scheme for XMPP is defined in RFC 5122  and extended in XMPP URI Query Components (XEP-0147)  and Pre-Authenticated Roster Subscription (XEP-0379) . Furthermore, this heavily builds upon the blocks provided in XEP-0379 for landing page and roster subscription.
To create out-of-band invitation links, Romeo's server needs to implement the Ad-Hoc Commands (XEP-0050)  commands specified in the following section, and his client must be able to execute them.
Furthermore, Romeo's server SHOULD provide a HTTPS service hosting the landing page.
TODO: use appropriate node namespace.
A user can execute the 'invite' command to obtain a new invitation link with a unique invitation token.
The token should be unique, sufficiently long and generated by a strong random number generator.
The ibr query component in the XMPP URI indicates that the invitee is allowed to create an account on Romeo's server, using the 'preauth' token. If the server does not support or allow in-band registration for invited users, the server MUST omit the ibr query component.
Additionally, the server SHOULD provide the landing-url field which contains an HTTPS URL of a web-based landing page as described in Pre-Authenticated Roster Subscription (XEP-0379)  § 3.3. The URL format may differ from the example shown here depending on where the landing page is hosted.
If the server omits the landing-page field, Romeo's client SHOULD generate an appropriate landing page URL hosted by the client developer or a trusted third party.
A server MAY provide a field which provides the expiration date of the generated token. The expiration date MUST conform to the DateTime profile specified in XMPP Date and Time Profiles (XEP-0082) . If the field is not provided, the token does not expire.
Romeo's client should provide adequate means to export the landing-page URL, possibly accompanied with a short description and the expire information, so that Romeo can share it with Juliet by other means than XMPP, like e-mail or a QR code.
A short text that this is an XMPP invitation from Romeo.
A client recommendation (based on the detected web browser/OS) with download links.
A prominent button that activates the encoded xmpp: link.
If the landing page is hosted by Romeo's server, the server MAY display additional information based on the supplied TOKEN value, like the name of the inviter or validity information.
If Juliet does not have an XMPP client installed, she will not be able to open the xmpp: link from the invitation page. For this case, the landing page needs to indicate that a client must be installed first, and that the link will not work as intended without. The automatic installation of an appropriate IM client when a user clicks on an xmpp: is outside of the scope of this document.
If Juliet's client is already configured with an account, the default action for the presented xmpp:inviter@example.com?roster;... URI is to add the inviter to Juliet's roster. This should be performed as described in §3.4 of XEP-0379, by sending a presence subscription request containing the 'preauth' token.
If Juliet already has Romeo in her roster, her client should open the appropriate chat interface instead.
Login with an existing XMPP account.
Register an account with Romeo's server (if the URI contains a ibr=y parameter).
Register an account with a public or client-endorsed server.
If the xmpp: URI provided by Romeo contains the ibr=y parameter, it indicates that the server supports the Pre-Authenticated In-Band Registration defined in this document. If Juliet chooses this approach, the server will ensure that after the registration, Romeo is added to her roster with a full presence subscription.
If Juliet chooses to login or register with a different server, her client must complete the respective process and issue a subscription request as described in §3.4 of XEP-0379.
If Romeo is the administrator of an XMPP server, he might want to ensure that Juliet obtains an account on this server, with a username defined either by Romeo or by Juliet, and in a way that does not require the out-of-band communication of user passwords.
TODO: description of overall process steps, design motivation.
A server MAY require a username to be specified for account creation. In this case, the server MUST add the <required/> element to the username field. The username MUST be a valid localpart as defined in RFC 6122  §2.3.
After the invitee has successfully registered on the inviter's server and roster subscription is enabled for account creation, the server MUST use roster pushes as defined in RFC 6121  §2.1.6 in order to inform the inviter about the invitee's new account without the need to reconnect.
If the inviter's server does not support user invitation, the client application SHOULD silently fall back to Pre-Authenticated Roster Subscription (XEP-0379)  for a good user experience.
If a username was specified during the account creation process, the server SHOULD NOT create an account on the server until the invitee actually registers it with the corresponding token. The server MUST reserve the username at least until the corresponding token expires.
If the invitee opens an invitation URI with ibr=y and chooses to create a new account, the client SHOULD pre-fill the inviter JID's domain part as the new account's domain. The client MAY provide a mechanism to enter or choose a different server, though.
See security considerations in Pre-Authenticated Roster Subscription (XEP-0379) .
As authorized by XMPP URI Query Components (XEP-0147) , the XMPP Registrar maintains a registry of queries and key-value pairs for use in XMPP URIs (see <https://xmpp.org/registrar/querytypes.html>).
In addition to the preauth key-value parameter define in Pre-Authenticated Roster Subscription (XEP-0379) , the ibr parameter is added to the roster query action.
1. RFC 5122: Internationalized Resource Identifiers (IRIs) and Uniform Resource Identifiers (URIs) for the Extensible Messaging and Presence Protocol (XMPP) <http://tools.ietf.org/html/rfc5122>.
2. XEP-0147: XMPP URI Query Components <https://xmpp.org/extensions/xep-0147.html>.
3. XEP-0379: Pre-Authenticated Roster Subscription <https://xmpp.org/extensions/xep-0379.html>.
4. XEP-0050: Ad-Hoc Commands <https://xmpp.org/extensions/xep-0050.html>.
5. XEP-0082: XMPP Date and Time Profiles <https://xmpp.org/extensions/xep-0082.html>.
6. RFC 6122: Extensible Messaging and Presence Protocol (XMPP): Address Format <http://tools.ietf.org/html/rfc6122>.
7. XEP-0077: In-Band Registration <https://xmpp.org/extensions/xep-0077.html>.
8. RFC 6121: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://tools.ietf.org/html/rfc6121>.
Used Data Forms for extension of In-Band Registration as required by XEP-0077 § 4.
Added "defined condition" elements in error stanzas as required by RFC 6120 § 8.3.2.
Changed type of "invalid-token" error to "modify".
Accepted by vote of Council on 2018-01-17.

References: § 3
 §3
 §3
 §2
 §2
 § 4
 § 8