-
Notifications
You must be signed in to change notification settings - Fork 226
Adjusting CAIP-171 as per last meeting #173
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
Changes from all commits
075df93
ab7b488
a121ee9
5bf4cff
aa179bf
df89542
de6e930
7f03ba0
3260a33
da7e63a
f6c9c61
4b0fa47
47d95b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| --- | ||
| caip: 171 | ||
| title: Session Identifiers | ||
| author: Olaf Tomalka (@ritave) | ||
| discussions-to: <URL> | ||
| status: Draft | ||
| type: Standard | ||
| created: 2022-11-09 | ||
| --- | ||
|
|
||
| ## Simple Summary | ||
|
|
||
| This CAIP defines an common identifier for representing an open session with a | ||
| wallet, including both in-browser session tokens and API-based connection IDs. | ||
|
|
||
| ## Motivation | ||
|
|
||
| Currently, sessions with wallet clients are tracked differently across different | ||
| architectures: in-browser MetaMask sandboxes instance-specific connections based | ||
| on origin which are referred to by tokens in the browser, while WalletConnect | ||
| uses a topic-based pub/sub protocol keyed to a unique topic string, etc. | ||
| Aligning specific aspects of session state can be hard without shared | ||
| assumptions about session boundaries and tracking. A minimal assumption is that | ||
| sessions are tracked by identifiers, and that different actors can update the | ||
| session accordingly. | ||
|
|
||
| ## Specification | ||
|
|
||
| > Such sections are considered non-normative. | ||
|
|
||
| ### Language | ||
|
|
||
| The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", | ||
| "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" written in | ||
| uppercase in this document are to be interpreted as described in [RFC | ||
| 2119](https://www.ietf.org/rfc/rfc2119.txt) | ||
|
|
||
| ### Definition | ||
|
|
||
| Whenever a CAIP uses the name `SessionIdentifier` and has this CAIP in the | ||
| `required` front-matter property, it SHALL be interpreted as reference to this | ||
| specification. | ||
|
|
||
| > Notice that there are no code constraints on the token value. This is by | ||
| > design and the value is implementation-dependent. | ||
|
|
||
| ```typescript | ||
| type SessionIdentifier = string; | ||
| ``` | ||
|
|
||
| Properties of the `SessionIdentifier` are as follows: | ||
| 1. It MUST uniquely identify an open and stateful session. | ||
|
bumblefudge marked this conversation as resolved.
|
||
| 2. It MUST identify a closeable session, and it MUST become invalid | ||
| after a session is closed. | ||
| 3. It MUST remain the same as the identified session's state changes. | ||
| 4. It MUST be serializable into JSON. Serialization and later deserialization using | ||
| JSON MUST result in the same value. | ||
|
|
||
| ## Copyright | ||
|
|
||
| Copyright and related rights waived via | ||
| [CC0](https://creativecommons.org/publicdomain/zero/1.0/). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also I'd suggest having the CC0 in the LICENSE file of this repo as well. That's what we do in Snaps Improvement Proposals |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ status: Draft | |
| type: Standard | ||
| created: 2020-10-14 | ||
| updated: 2022-10-26 | ||
| requires: [2, 10] | ||
| requires: [2, 10, 171] | ||
| --- | ||
|
|
||
| ## Simple Summary | ||
|
|
@@ -66,7 +66,6 @@ given set of parameters by calling the following JSON-RPC request | |
| The JSON-RPC method is labelled as `provider_authorization` and expects one or | ||
| more objects each named after the pertinent ChainAgnostic namespace and each | ||
| containing with three parameters: | ||
|
|
||
| - chains - array of CAIP-2 compliant chainId's | ||
| - methods - array of JSON-RPC methods expected to be used during the session | ||
| - events - array of JSON-RPC message/events expected to be emitted during the | ||
|
|
@@ -81,21 +80,23 @@ The wallet can respond to this method with either a success result or an error m | |
| The response MUST be a success result when the user approved accounts matching | ||
| the requested chains to be exposed and the requested methods to be used. | ||
|
|
||
| The response MUST include `session` which is a `SessionIdentifier` as defined in [caip-171](./caip-171). | ||
|
|
||
| An example of a successful response should match the following format: | ||
|
|
||
| ```jsonc | ||
| { | ||
| "id": 1, | ||
| "jsonrpc": "2.0", | ||
| "result": { | ||
| "session": "0xdeadbeef", | ||
| "accounts": ["eip155:1:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb"] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| The accounts returned as a result should match the requested `chainId`s and | ||
| should be an array of CAIP-10 compliant `accountId`s. | ||
|
|
||
| #### Failure States | ||
|
|
||
| The response MUST NOT be a success result when the user disapproves the accounts | ||
|
|
@@ -117,29 +118,30 @@ An example of an error response should match the following format: | |
| ``` | ||
|
|
||
| The valid error messages codes are the following: | ||
|
|
||
| - When user disapproves exposing accounts to requested chains | ||
| - code = 5000 | ||
| - message = "User disapproved requested chains" | ||
| - When user disapproves accepting calls with the request methods | ||
| - code = 5001 | ||
| - message = "User disapproved requested methods" | ||
| - When user disapproves accepting calls with the request events | ||
| - code = 5002 | ||
| - message = "User disapproved requested events" | ||
| - When wallet evaluates requested chains to not be supported | ||
| - code = 5100 | ||
| - message = "Requested chains are not supported" | ||
| - When wallet evaluates requested methods to not be supported | ||
| - code = 5101 | ||
| - message = "Requested methods are not supported" | ||
| - When wallet evaluates requested events to not be supported | ||
| - code = 5102 | ||
| - message = "Requested events are not supported" | ||
|
|
||
| ## Links | ||
|
|
||
| n/a | ||
| * When user disapproves exposing accounts to requested chains | ||
| * code = 5000 | ||
| * message = "User disapproved requested chains" | ||
| * When user disapproves accepting calls with the request methods | ||
| * code = 5001 | ||
| * message = "User disapproved requested methods" | ||
| * When user disapproves accepting calls with the request events | ||
| * code = 5002 | ||
| * message = "User disapproved requested events" | ||
| * When wallet evaluates requested chains to not be supported | ||
| * code = 5100 | ||
| * message = "Requested chains are not supported" | ||
| * When wallet evaluates requested methods to not be supported | ||
| * code = 5101 | ||
| * message = "Requested methods are not supported" | ||
| * When wallet evaluates requested events to not be supported | ||
| * code = 5102 | ||
| * message = "Requested events are not supported" | ||
|
|
||
| ## Changelog | ||
|
|
||
| - 2022-11-26: add mandatory indexing by session identifier (i.e. CAIP-171 requirement) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a Draft, imho the changelog shouldn't be in it until it's Final, where we could add Errata. |
||
| - 2022-10-26: Addressed Berlin Gathering semantics issues and params syntax; | ||
| consolidated variants across issues and forks post-Amsterdam Gathering | ||
|
|
||
| ## Copyright | ||
|
|
||
|
|
||
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.