]>
A JSON Meta Application Protocol (JMAP) Subprotocol for WebSocket
FastMail US LLC1429 Walnut Street - Suite 1201PhiladelphiaPA19102USAmurch@fastmailteam.comART
JMAPjmapwebsocketThis document defines a binding for the JSON Meta Application
Protocol (JMAP) over a WebSocket transport layer. A WebSocket
binding for JMAP provides higher performance than the current
HTTP binding for JMAP.
What mechanism should be used to allow the client to
choose what types of objects for which is wishes to receive
push notifications over the WS connection? Shoul this be
done via a new method type or can it be done with header
fields and/or query parameters on the WS handshake?JMAP over HTTP requires that every JMAP API request be
authenticated. Depending on the type of authentication used by
the JMAP client and the configuration of the JMAP server,
authentication could be an expensive operation both in time and
resources. In such circumstances, authenticating every JMAP API
request may harm performance.The WebSocket binding for JMAP eliminates this performance
hit by authenticating just the WebSocket handshake request and
having those credentials remain in effect for the duration of
the WebSocket connection.Furthermore, the WebSocket binding for JMAP can optionally
compress JMAP API requests.
Although compression of HTTP responses is ubiquitous,
compression of HTTP requests has very low, if any deployment,
and therefore isn't a viable option for JMAP API requests over
HTTP.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
when, and only when, they appear in all capitals, as shown
here.The same terminology is used in this document as in the core
JMAP specification.The capabilities object is returned as part of the standard
JMAP Session object (see Section 2 of
).
Servers supporting this specification MUST add a property called
"urn:ietf:params:jmap:websocket" to the capabilities object.
The value of this property is an object which MUST contain the
following information on server capabilities:
"String" The URL to use for JMAP over WebSocket.
The term WebSocket subprotocol refers to an application-level
protocol layered on top of a WebSocket connection. This
document specifies the WebSocket JMAP subprotocol for carrying
JMAP API requests, responses, and push notifications
through a WebSocket connection.
Binary data MUST NOT be uploaded or downloaded through a
WebSocket JMAP connection.The JMAP WebSocket client and JMAP WebSocket server
negotiate the use of the WebSocket JMAP subprotocol during
the WebSocket handshake, either via a HTTP/1.1 Upgrade request
(see Section 1.3 of )
or a HTTP/2 Extended CONNECT request (see Section 5 of
).Regardless of the method used for the WebSocket handshake,
the client MUST make an
authenticated HTTP request on the JMAP 'wsURL', and the
client MUST include the value 'jmap' in the list of protocols
for the 'Sec-WebSocket-Protocol' header field.
The reply from the server MUST also contain 'jmap' in its
corresponding 'Sec-WebSocket-Protocol' header field in order
for a JMAP subprotocol connection to be established.If a client receives a handshake response that does not
include 'jmap' in the 'Sec-WebSocket-Protocol' header, then a
JMAP subprotocol WebSocket connection was not established and
the client MUST close the WebSocket connection.Once the handshake has successfully completed, the
WebSocket connection is established and can be used for JMAP
API requests, responses, and push notifications.
Any other message types MUST NOT be transmitted over this
connection.The credentials used for authenticating the HTTP request
to initiate the handshake remain in effect for the duration
of the WebSocket connection.Data frame messages in the JMAP subprotocol MUST be of the
text type and contain UTF-8 encoded data. The messages MUST
be in the form of a single JMAP Request object (see Section
3.2 of ) when sent from
the client to the server, and in the form of a single JMAP
Response object, JSON Problem Details object, or JMAP StateChange
object (see Sections 3.3, 3.5.1, and 7.1 respectively of
) when sent from the
server to the client.JMAP over WebSocket allows out of order processing of
requests, thereby requiring a mechanism for the client to
correlate requests and responses.To this end, this specification adds one extra argument
to the request object:
*id*: "String" (default: ) A client-specified
identifier for the request.Additionally, the "maxConcurrentRequests" field in the
"capabilities" object (see Section 2 of
) limits the number of
inflight requests over the WebSocket.This specification adds two extra arguments to the
Response object:
*@type*: "String" A string having value "Response"
to identify the JSON object as a JMAP Response.*requestId*: "String|null" The client-specified identifier
in the corresponding request. If "null", no identifier
was provided in the request.This specification adds two extra arguments to the
Problem Details object:
*@type*: "String" A string having value "RequestError"
to identify the JSON object as a JSON Problem Details
object.*requestId*: "String|null" The client-specified identifier
in the corresponding request. If "null", no identifier
was provided in the request.This specification adds one extra argument to the
StateChange object:
*@type*: "String" A string having value "StateChange"
to identify the JSON object as a JMAP StateChange object.The following examples show WebSocket JMAP opening
handshakes, a JMAP Core/echo request and response, and a
subsequent closing handshake.
The examples assume that the JMAP 'wsURL' has been advertised
in the JMAP Session object as '/jmap/ws/'.
Note that folding of header fields is for editorial purposes
only.
WebSocket JMAP connection via HTTP/1.1:
WebSocket JMAP connection on a HTTP/2 stream which also
negotiates compression:
The security considerations for both WebSocket (see Section
10 of ) and JMAP (see Section 8 of
) apply to the WebSocket
JMAP subprotocol.This specification requests IANA to register the WebSocket
JMAP subprotocol under the "WebSocket Subprotocol Name"
Registry with the following data:
JMAP
WebSocket Transport for JMAP (JSON Meta Application Protocol)RFCXXXX (this document)The author would like to thank the following individuals for
contributing their ideas and support for writing this
specification: Neil Jenkins and Robert Mueller.
&rfc2119;
&rfc6455;
&rfc7235;
&rfc8174;
&rfc8441;
&idJMAPCore;
&rfc7692;
&idJMAPMail;
Changes since murchison-02:
Renamed as a JMAP WG document.Allow out of order processing.Allow push notifications.Modified examples.Add Security Considerations text.Minor Editorial changes.Changes since murchison-01:
Updated WebSocket over HTTP/2 reference to RFC8144.Changes since murchison-00:
Fleshed out section on discovery of support for JMAP over
WebSocket.Allow JSON Problem Details objects to be returned by the
server for toplevel errors.Mentioned the ability to compress JMAP API requests.Minor Editorial changes.