@@ -656,24 +656,136 @@ homeserver to look up the alias.
656
656
Room aliases MUST NOT exceed 255 bytes (including the ` # ` sigil and the
657
657
domain).
658
658
659
- #### matrix.to navigation
659
+ #### URIs
660
+
661
+ There are two major kinds of referring to a resource in Matrix: matrix.to
662
+ and ` matrix: ` URI. The specification currently defines both as active/valid
663
+ ways to refer to entities/resources.
664
+
665
+ Rooms, users, and aliases may be represented as a URI. This URI can
666
+ be used to reference particular objects in a given context, such as mentioning
667
+ a user in a message or linking someone to a particular point in the room's
668
+ history (a permalink).
669
+
670
+ ##### Matrix URI scheme
671
+
672
+ {{% added-in v="1.2" %}}
673
+
674
+ The Matrix URI scheme is defined as follows (` [] ` enclose optional parts, ` {} `
675
+ enclose variables):
676
+ ```
677
+ matrix:[//{authority}/]{type}/{id without sigil}[/{type}/{id without sigil}...][?{query}][#{fragment}]
678
+ ```
679
+
680
+ As a schema, this can be represented as:
681
+
682
+ ```
683
+ MatrixURI = "matrix:" hier-part [ "?" query ] [ "#" fragment ]
684
+ hier-part = [ "//" authority "/" ] path
685
+ path = entity-descriptor ["/" entity-descriptor]
686
+ entity-descriptor = nonid-segment / type-qualifier id-without-sigil
687
+ nonid-segment = segment-nz ; as defined in RFC 3986
688
+ type-qualifier = segment-nz "/" ; as defined in RFC 3986
689
+ id-without-sigil = string ; as defined in Matrix identifier spec above
690
+ query = query-element *( "&" query-item )
691
+ query-item = action / routing / custom-query-item
692
+ action = "action=" ( "join" / "chat" )
693
+ routing = "via=” authority
694
+ custom-query-item = custom-item-name "=" custom-item-value
695
+ custom-item-name = 1*unreserved ; reverse-DNS name
696
+ custom-item-value =
697
+ ```
698
+
699
+ Note that this format is deliberately following [ RFC 3986] ( https://tools.ietf.org/html/rfc3986 )
700
+ to ensure maximum compatibility with existing tooling. The scheme name (` matrix ` ) is
701
+ registered alongside other schemes by the IANA [ here] ( https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml ) .
702
+
703
+ Currently, the ` authority ` and ` fragment ` are unused by this specification,
704
+ though are reserved for future use. Matrix does not have a central authority which
705
+ could reasonably fill the ` authority ` role. ` nonid-segment ` in the schema is
706
+ additionally reserved for future use.
707
+
708
+ The ` type ` denotes the kind of entity which is described by ` id without sigil ` .
709
+ Specifically, the following mappings are used:
710
+
711
+ * ` r ` for room aliases.
712
+ * ` u ` for users.
713
+ * ` roomid ` for room IDs (note the distinction from room aliases).
714
+ * ` e ` for events, when after a room reference (` r ` or ` roomid ` ).
660
715
661
716
{{% boxes/note %}}
662
- This namespacing is in place pending a ` matrix:// ` (or similar) URI
663
- scheme. This is ** not** meant to be interpreted as an available web
664
- service - see below for more details.
717
+ During development of this URI format, types of ` user ` , ` room ` , and ` event `
718
+ were used: these MUST NOT be produced any further, though implementations might
719
+ wish to consider handling them as ` u ` , ` r ` , and ` e ` respectively.
720
+
721
+ ` roomid ` was otherwise unchanged.
665
722
{{% /boxes/note %}}
666
723
667
- Rooms, users, aliases, and groups may be represented as a "matrix.to"
668
- URI. This URI can be used to reference particular objects in a given
669
- context, such as mentioning a user in a message or linking someone to a
670
- particular point in the room's history (a permalink).
724
+ The ` id without sigil ` is simply the identifier for the entity without the defined
725
+ sigil. For example, ` !room:example.org ` becomes ` room:example.org ` (` ! ` is the sigil
726
+ for room IDs). The sigils are described under the
727
+ [ Common Identifier Format] ( #common-identifier-format ) .
728
+
729
+ The ` query ` is optional and helps clients with processing the URI's intent. In
730
+ this specification are the following:
731
+
732
+ * ` action ` - Helps provide intent for what the client should do specifically with
733
+ the URI. Lack of an ` action ` simply indicates that the URI is identifying a resource
734
+ and has no suggested action associated with it - clients could treat this as
735
+ navigating the user to an informational page, for example.
736
+ * ` action=join ` - Describes an intent for the client to join the room described
737
+ by the URI and thus is only valid on URIs which are referring to a room (it
738
+ has no meaning and is ignored otherwise). The client should prompt for confirmation
739
+ prior to joining the room, if the user isn't already part of the room.
740
+ * ` action=chat ` - Describes an intent for the client to start/open a DM with
741
+ the user described by the URI and thus is only valid on URIs which are referring
742
+ to a user (it has no meaning and is ignored otherwise). Clients supporting a
743
+ form of Canonical DMs should reuse existing DMs instead of creating new ones
744
+ if available. The client should prompt for confirmation prior to creating the
745
+ DM, if the user isn't being redirected to an existing canonical DM.
746
+ * ` via ` - Can be used to denote which servers (` authority ` grammar) to attempt to resolve
747
+ the resource through, or take ` action ` through. An example of using ` via ` for
748
+ routing Room IDs is described [ below] ( #routing ) , and is encouraged for use in
749
+ Matrix URIs referring to a room ID. Matrix URIs can additionally use this ` via `
750
+ parameter for non-public federation resolution of identifiers (i.e.: listing a
751
+ server which might have information about the given user) while a more comprehensive
752
+ way is being worked out, such as one proposed by [ MSC3020] ( https://github.com/matrix-org/matrix-doc/pull/3020 ) .
753
+
754
+ Custom query parameters can be specified using the
755
+ [ Common Namespaced Identifier format] ( #common-namespaced-identifier-grammar ) and
756
+ appropriately encoding their values. Specifically, "percent encoding" and encoding
757
+ of the ` & ` are required. Where custom parameters conflict with specified ones,
758
+ clients should prefer the specified parameters. Clients should strive to maintain
759
+ consistency across custom parameters as users might be using multiple different
760
+ clients across multiple different authors. Useful and mission-aligned custom
761
+ parameters should be proposed to be included in this specification.
762
+
763
+ Examples of common URIs are:
764
+
765
+ <!-- Author's note: These examples should be consistent with the matrix.to counterparts. -->
766
+ * Link to ` #somewhere:example.org ` : ` matrix:r/somewhere:example.org `
767
+ * Link to ` !somewhere:example.org ` : ` matrix:roomid/somewhere:example.org?via=elsewhere.ca `
768
+ * Link to ` $event ` in ` #somewhere:example.org ` : ` matrix:r/somewhere:example.org/e/event `
769
+ * Link to ` $event ` in ` !somewhere:example.org ` : ` matrix:roomid/somewhere:example.org/e/event?via=elsewhere.ca `
770
+ * Link to chat with ` @alice:example.org ` : ` matrix:u/alice:example.org?action=chat `
771
+
772
+ A suggested client implementation algorithm is available in the
773
+ [ original MSC] ( https://github.com/matrix-org/matrix-doc/blob/main/proposals/2312-matrix-uri.md#recommended-implementation ) .
774
+
775
+ ##### matrix.to navigation
776
+
777
+ {{% boxes/note %}}
778
+ This namespacing existed prior to a ` matrix: ` scheme. This is ** not**
779
+ meant to be interpreted as an available web service - see below for more
780
+ details.
781
+ {{% /boxes/note %}}
671
782
672
783
A matrix.to URI has the following format, based upon the specification
673
- defined in RFC 3986:
784
+ defined in [ RFC 3986] ( https://tools.ietf.org/html/rfc3986 ) :
674
785
675
- > < https://matrix.to/#/ > < ; identifier> ; /< ; extra
676
- > parameter> ; ?< ; additional arguments> ;
786
+ ```
787
+ https://matrix.to/#/<identifier>/<extra parameter>?<additional arguments>
788
+ ```
677
789
678
790
The identifier may be a room ID, room alias, user ID, or group ID. The
679
791
extra parameter is only used in the case of permalinks where an event ID
@@ -694,13 +806,12 @@ The components of the matrix.to URI (`<identifier>` and
694
806
695
807
Examples of matrix.to URIs are:
696
808
697
- - Room alias: ` https://matrix.to/#/%23somewhere%3Aexample.org `
698
- - Room: ` https://matrix.to/#/!somewhere%3Aexample.org `
699
- - Permalink by room:
700
- ` https://matrix.to/#/!somewhere%3Aexample.org/%24event%3Aexample.org `
701
- - Permalink by room alias:
702
- ` https://matrix.to/#/%23somewhere:example.org/%24event%3Aexample.org `
703
- - User: ` https://matrix.to/#/%40alice%3Aexample.org `
809
+ <!-- Author's note: These examples should be consistent with the matrix scheme counterparts. -->
810
+ * Link to ` #somewhere:example.org ` : ` https://matrix.to/#/%23somewhere%3Aexample.org `
811
+ * Link to ` !somewhere:example.org ` : ` https://matrix.to/#/!somewhere%3Aexample.org?via=elsewhere.ca `
812
+ * Link to ` $event ` in ` #somewhere:example.org ` : ` https://matrix.to/#/%23somewhere:example.org/%24event%3Aexample.org `
813
+ * Link to ` $event ` in ` !somewhere:example.org ` : ` https://matrix.to/#/!somewhere%3Aexample.org/%24event%3Aexample.org?via=elsewhere.ca `
814
+ * Link to ` @alice:example.org ` : ` https://matrix.to/#/%40alice%3Aexample.org `
704
815
705
816
{{% boxes/note %}}
706
817
Historically, clients have not produced URIs which are fully encoded.
@@ -730,20 +841,17 @@ may not be encoded).
730
841
731
842
Room IDs are not routable on their own as there is no reliable domain to
732
843
send requests to. This is partially mitigated with the addition of a
733
- ` via ` argument on a matrix.to URI, however the problem of routability is
844
+ ` via ` argument on a URI, however the problem of routability is
734
845
still present. Clients should do their best to route Room IDs to where
735
846
they need to go, however they should also be aware of [ issue
736
847
\# 1579] ( https://github.com/matrix-org/matrix-doc/issues/1579 ) .
737
848
738
849
A room (or room permalink) which isn't using a room alias should supply
739
- at least one server using ` via ` in the ` <additional arguments> ` , like
740
- so:
741
- ` https://matrix.to/#/!somewhere%3Aexample.org?via=example.org&via=alt.example.org ` .
742
- The parameter can be supplied multiple times to specify multiple servers
743
- to try.
850
+ at least one server using ` via ` in the URI's query string. Multiple servers
851
+ can be specified by including multuple ` via ` parameters.
744
852
745
853
The values of ` via ` are intended to be passed along as the ` server_name `
746
- parameters on the Client Server ` /join ` API.
854
+ parameters on the [ Client Server ` /join/{roomIdOrAlias} ` API] ( /client-server-api/#post_matrixclientv3joinroomidoralias ) .
747
855
748
856
When generating room links and permalinks, the application should pick
749
857
servers which have a high probability of being in the room in the
0 commit comments