-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] MWA Specification - WebSocket Data Encoding Disambiguation #1094
base: main
Are you sure you want to change the base?
Conversation
spec/spec.md
Outdated
1. The `com.solana.mobilewalletadapter.v1.base64` subprotocol indicates that the server supports UTF-8 text WebSocket data frames. When This protocol is in use, endpoints can send and receive paylaods as Base64 encoded text using a UTF-8 text data frame. | ||
1. The `com.solana.mobilewalletadapter.v1.reflector` subprotocol is used by WebSocket reflectors when connecting to a [Remote URI](#remote-uri). | ||
|
||
When connecting to a [Local URI](#local-uri), the dapp endpoint must request both the `com.solana.mobilewalletadapter.v1` and `com.solana.mobilewalletadapter.v1.base64` WebSocket subprotocols. The wallet endpoint must respond with one or both of the `com.solana.mobilewalletadapter.v1` and `com.solana.mobilewalletadapter.v1.base64` WebSocket subprotocols to indicate to the dapp endpoint whether it supports either the binary or base64 encoded data frames, or both. When connecting to a [Remote URI](#remote-uri), the both the dapp and wallet endpoints must request, and the reflector server must respond with, the `com.solana.mobilewalletadapter.v1.reflector` WebSocket subprotocol in addition to one or both of the `com.solana.mobilewalletadapter.v1` and `com.solana.mobilewalletadapter.v1.base64` subprotocols. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sdlaver I have initially wrote this to allow servers to support both binary and text frames simultaneously, if they choose. Do you think we should make this so that servers should define just one of these, not both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of a good reason to support intermixing binary and text frames, no. At best, it's functionality-neutral with picking one or the other, and at worst, it adds complexity and an opportunity for implementation bugs. I'd lean on the protocol negotiation capabilities of websockets, and have the server select one or the other, but not both.
This spec change fixes an existing bug in the Mobile Wallet Adapter WebSocket transport specification.
The WebSocket protocol defines support for both binary data frames and text data frames. Binary data frames allow endpoints to exchange raw binary payloads while text data frames contain UTF-8 encoded data. Currently the MWA spec does not specify which data frames are supported or how payloads should be encoded for either data frame.
Currently, our MWA implementations use raw, unencoded binary data frames to exchange the encrypted payloads. Since not all binary payloads are valid UTF-8, the use of text data frames is not valid behavior. This update to the specification disambiguates this behavior for the existing
com.solana.mobilewalletadapter.v1
WebSocket subprotocol and defines a newcom.solana.mobilewalletadapter.v1.base64
subprotocol to allow payloads to be sent as UFT-8 encoded text frames with a shared understanding of how those payloads will be encoded/decoded by the endpoints.