w3c / openscreenprotocol

Open Screen Protocol
https://www.w3.org/TR/openscreenprotocol/
Other
93 stars 22 forks source link

Suggestion: ephemeral application transports #351

Open backkem opened 2 weeks ago

backkem commented 2 weeks ago

I've been thinking about the interaction between the network and application protocol and the interaction between OSP agents and origins.

Some properties that I deem valuable:

To make the network protocol usable for a broad range of protocols, we need a good abstraction. One option would be to mux application transports over the network protocol. However, this comes with a potential performance impact of encapsulation, and encapsulation of different protocols also has a higher cost of implementation. Another options is to facilitate opening new TLS connections to transport application protocols. This doesn't come with the performance and implementation costs mentioned above. As an added advantage, it is already a popular abstraction used by many protocols. To open a TLS connection on the local area network you generally need: the target address (dns / ip and port) and target TLS certificate (Since we can't rely on Public Key Infrastructure). I'll refer to this as "connection materials" going forward. Note: for now I've only been talking about the protocol level, I'm not talking about browser APIs yet.

Since we're building a protocol to be usable in the context of a browser, there's an additional need to support a broader range of protocols and that's how to construct them with a browser API. However, this requires making sure we don't expose persistant identification to the JS Realm to avoid fingerprinting. One way to do this would be to create new constructors for all transports that we want to construct. However, this again adds implementation cost per protocol. Another option would be to expose the connection materials to the JS Realm. This would have far broader applicability; but it can only be done if the connection materials only contain ephemeral information.

So, this is where the above suggestion comes in. We extend the network protocol with the ability to allocate new ephemeral (remote) connection materials. The connection materials can be exposed to the JS Realm to allow any TLS-based transport to be constructed. The overall flow would be:

  1. A device (TV) has an advertising agent.
  2. The user agent has listening agent.
  3. The user agent finds the device and performs authentication.
  4. An origin requests to cast.
  5. the user agent prompts for permission and let's the user select the appropriate advertising agent (device/TV).
  6. The user agent sends a new network protocol message to the device to request a new connection materials. This message should probably contain some indication of the purpose of the connection being allocated. This is to be defined further.
  7. The device allocates a new random mdns address (E.g. UUID.local) and a new ephemeral certificate for this endpoint. The device sends a response to the user agent with the newly created connection materials.
  8. The user agent passes the newly created connection materials to the origin.
  9. The origin JS code constructs the transport it needs.

Opening a new connection is done by repeating the above steps from step 4.

This approach gives us the following properties:

Open points I can think of:

I'd love to hear your thoughts @markafoltz, @wangw-1991, @pthatcherg, @anssiko.