https://github.com/ssbc/ssb-uri-spec
Specification of SSB URIs
https://github.com/ssbc/ssb-uri-spec
Last synced: 5 months ago
JSON representation
Specification of SSB URIs
- Host: GitHub
- URL: https://github.com/ssbc/ssb-uri-spec
- Owner: ssbc
- Created: 2021-03-10T12:26:49.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-10-27T11:19:42.000Z (over 3 years ago)
- Last Synced: 2025-10-14T18:22:30.749Z (9 months ago)
- Size: 46.9 KB
- Stars: 16
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSES/CC-BY-4.0.txt
Awesome Lists containing this project
README
# SSB URI Specification
Version: 1.3
Author: Andre 'Staltz' Medeiros
License: This work is licensed under a Creative Commons Attribution 4.0 International License.
## Abstract
The `ssb` scheme is registered as [provisional under the IANA](https://www.iana.org/assignments/uri-schemes/prov/ssb), but its format is not yet specified accessibly and clearly. This documents aims at providing the first specification of SSB URIs, as they are used in existing applications and will be adopted increasingly in more use cases.
## Terminology
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119).
## Prior work
There is a thread on SSB, `%g3hPVPDEO1Aj/uPl0+J2NlhFB2bbFLIHlty+YuqFZ3w=.sha256`, where several participants gave their thoughts on the design of the SSB URI format, with several proposals put into consideration. The format of Query-only URIs were inspired by [Magnet URIs](https://www.iana.org/assignments/uri-schemes/prov/magnet).
[ssb-uri](https://github.com/fraction/ssb-uri) is one outcome of that discussion, and is referred to in the IANA page. The `ssb-uri` library is depended on in [Patchwork](https://github.com/ssbc/patchwork/). As an alternative library, [ssb-custom-uri](https://git.sr.ht/~soapdog/ssb-custom-uri) is used in [Patchfox](https://github.com/soapdog/patchfox/). [Patchfoo](https://git.scuttlebot.io/%25YAg1hicat%2B2GELjE2QJzDwlAWcx0ML%2B1sXEdsWwvdt8%3D.sha256) supports both `ssb-uri` and `ssb-custom-uri`. [Manyverse](https://manyver.se) supports the URIs in this specification via the library [ssb-uri2](https://github.com/staltz/ssb-uri2).
The specification in this document is compatible with `ssb-uri` while adding support for expressing more resources.
## List
- **Canonical SSB URIs**
- `ssb:message/classic/`
- `ssb:message/bendybutt-v1/`
- `ssb:message/gabbygrove-v1/`
- `ssb:message/buttwoo-v1/`
- `ssb:message/indexed-v1/`
- `ssb:message/cloaked/`
- `ssb:feed/classic/`
- `ssb:feed/bendybutt-v1/`
- `ssb:feed/gabbygrove-v1/`
- `ssb:feed/buttwoo-v1/`
- `ssb:feed/buttwoo-v1//`
- `ssb:feed/indexed-v1/`
- `ssb:blob/classic/`
- `ssb:address/multiserver?multiserverAddress=`
- `ssb:encryption-key/box2-dm-dh/`
- `ssb:identity/po-box/`
- `ssb:identity/group/`
- `ssb:identity/fusion/`
- **Experimental SSB URIs**
- `ssb:experimental?action=claim-http-invite&invite=&multiserverAddress=`
- `ssb:experimental?action=consume-alias&alias=&userId=&signature=&roomId=&multiserverAddress=`
- `ssb:experimental?action=start-http-auth&sid=&sc=`
- **Deprecated SSB URIs**
- `ssb:message/sha256/`
- `ssb:feed/ed25519/`
- `ssb:blob/sha256/`
## Overview
There are two main categories of SSB URIs: **Canonical** and **Experimental**. The conceptual difference between these two is that canonical SSB URIs make use of the **path component** in the URI to specify the resource, while experimental SSB URIs use _only_ the **query component** to specify the resource.
The third category, **Deprecated**, is used to denote canonical SSB URIs that MUST still be supported by application, but SHOULD be avoided whenever possible.
### Canonical SSB URIs
These SSB URIs are to be considered stable and universally acceptable by all SSB applications that support SSB URIs. They utilize the path component to specify "refs", i.e. identifiers for resources. SSB messages, feeds, and blobs **SHOULD** follow the respective syntaxes:
```
ssb:message/classic/
ssb:message/bendybutt-v1/
ssb:message/gabbygrove-v1/
ssb:message/buttwoo-v1/
ssb:message/indexed-v1/
ssb:feed/classic/
ssb:feed/bendybutt-v1/
ssb:feed/gabbygrove-v1/
ssb:feed/buttwoo-v1/
ssb:feed/buttwoo-v1//
ssb:feed/indexed-v1/
ssb:blob/classic/
```
Where ``, ``, `` are _URI-safe Base64 encoded_ strings that identify those refs. URI-safe Base64 is equivalent to Base64 where `+` characters are replaced with `-`, and `/` characters are replaced with `_`.
In the special case of `ssb:feed/buttwoo-v1//`, the `` is the URI-safe Base64 encoded data of a buttwoo-v1 message URI (i.e. `` from `ssb:message/buttwoo-v1/`).
**Examples:**
```
ssb:message/classic/g3hPVPDEO1Aj_uPl0-J2NlhFB2bbFLIHlty-YuqFZ3w=
ssb:message/bendybutt-v1/PR2-btDEO1AjXuPl0TJ2N_hFB2bbFLIHlty0VF1ncty=
ssb:feed/classic/-oaWWDs8g73EZFUMfW37R_ULtFEjwKN_DczvdYihjbU=
ssb:feed/bendybutt-v1/APaWWDs8g73EZFUMfW37RBULtFEjwKNbDczvdYiRXtA=
ssb:feed/gabbygrove-v1/FY5OG311W4j_KPh8H9B2MZt4WSziy_p-ABkKERJdujQ=
ssb:blob/classic/sbBmsB7XWvmIzkBzreYcuzPpLtpeCMDIs6n_OJGSC1U=
```
There are also new concepts related to [Private Groups](https://github.com/ssbc/private-group-spec) which need identifiers, such as:
- `ssb:encryption-key/box2-dm-dh/`
- `ssb:identity/po-box/`
Where `` are _URI-safe Base64 encoded_ strings, similar to the previous canonical SSB URIs.
**Multiserver address:**
```
ssb:address/multiserver?multiserverAddress=
```
Where `` is a [multiserver address](https://github.com/ssbc/multiserver-address) string, but [percent-encoded according to RFC3986 2.1](https://tools.ietf.org/html/rfc3986#section-2.1), for example:
```
ssb:address/multiserver?multiserverAddress=net%3Awx.larpa.net%3A8008~shs%3ADTNmX%2B4SjsgZ7xyDh5xxmNtFqa6pWi5Qtw7cE8aR9TQ%3D
```
### Colon-separated canonical SSB URIs
Canonical SSB URIs **SHOULD** use `/` to separate the parts of the path component, but they **MAY** also use `:` to separate the parts. The following syntax is acceptable (and is currently what `ssb-uri` utilizes, exclusively):
```
ssb:message:classic:
ssb:message:bendybutt-v1:
ssb:feed:classic:
ssb:feed:bendybutt-v1:
ssb:blob:classic:
ssb:address:multiserver?multiserverAddress=
```
### Experimental SSB URIs
These SSB URIs are free-form and allow developers to pass any parameters to SSB applications without requiring consensus among the SSB applications. These URIs have an _empty authority_ component and path component always matching `experimental` (this is to support Firefox's handling of custom schemes) but have a _non-empty query_ component. The query parameters are the only mechanism through which information is conveyed. They satisfy the syntax below (any number of parameters allowed, but we show two, for illustration):
```
ssb:experimental?=
ssb:experimental?=&=
```
#### Known experimental SSB URIs
Experimental SSB URIs do not need to be included in this specification before they can be used, but we encourage developers to submit all known experimental SSB URIs depended by applications. This facilitates the future canonicalization of new SSB URIs. Please feel free to submit new entries here, as long as you know they are used in applications:
**Action to join a room:**
Some experimental SSB URIs have the query `action` to describe intents to perform certain tasks in the SSB application.
A `action=claim-http-invite` experimental URI is used to refer to the consumption of a [Rooms 2](https://github.com/ssb-ngi-pointer/rooms2) invite code, syntax as follows, which includes a `multiserverAddress` query like the canonical multiserver address URI has too:
```
ssb:experimental?action=claim-http-invite&invite=&multiserverAddress=`
```
**Action to consume an alias:**
A URI with query `action=consume-alias` allows us to refer to the processing [consuming a room alias](https://github.com/ssb-ngi-pointer/rooms2/blob/573cc4b3afc08a4eccaea530104524aa7f60af9f/docs/Alias/Alias%20consumption.md), syntax as follows:
```
ssb:experimental?action=consume-alias&alias=&userId=&signature=&multiserverAddress=&roomId=
```
**Action to start HTTP authentication:**
A URI with query `action=start-http-auth` is for initiating [Sign-in with SSB](https://github.com/ssb-ngi-pointer/rooms2/blob/573cc4b3afc08a4eccaea530104524aa7f60af9f/docs/Setup/Sign-in%20with%20SSB.md) (HTTP Authentication) with an SSB remote server. The syntax is as follows:
```
ssb:experimental?action=start-http-auth&sid=&sc=
```
### Process to canonicalize SSB URIs
When experimental SSB URIs are adopted by SSB applications, if they are deemed useful and long-term URIs, there should be discussion among stakeholders (SSB application developers, and protocol developers) to specify a canonical SSB URI format (using path component) to replace the experimental SSB URI. Then, the new canonical SSB URI should be specified in this document.
## Grammar
The following grammar specifies all SSB URIs (both canonical and any experimental) using [Nearley](https://nearley.js.org):
```nearley
uri -> scheme delimiter body
scheme -> "ssb"
delimiter -> ":"
separator -> [:/]
body -> parts1 (queries):? | parts3 (queries):? | parts4 (queries):?
parts1 -> type1
parts3 -> type3 separator alg3 separator value
parts4 -> type4 separator alg4 separator value separator value
queries -> "?" (query):+
query -> queryKey "=" queryVal
queryKey -> [a-zA-Z] ([^=]):*
queryVal -> [a-zA-Z0-9] ([^&]):*
type1 -> "experimental"
type3 -> "message" | "feed" | "blob" | "address" | "encryption-key" | "identity"
type4 -> "feed"
alg3 -> "classic" | "multiserver" | "bendybutt-v1" | "gabbygrove-v1" | "buttwoo-v1" | "indexed-v1" | "cloaked" | "box2-dm-dh" | "po-box" | "group" | "fusion"
alg4 -> "buttwoo-v1"
value -> ([0-9a-zA-Z\-\_\=]):+
```