feat: Add version discovery system

This commit is contained in:
Jesse Wierzbinski 2025-12-18 23:04:24 +01:00
parent f2a09a457f
commit 0bd532be3e
No known key found for this signature in database
8 changed files with 82 additions and 7 deletions

View file

@ -65,6 +65,7 @@ This is forbidden:
```http ```http
GET /.versia/v0.6/entities/user/1234 GET /.versia/v0.6/entities/user/1234
Host: example.com Host: example.com
Accept: application/vnd.versia+json
HTTP/1.1 301 Moved Permanently HTTP/1.1 301 Moved Permanently
Location: https://example.com/users/1234 Location: https://example.com/users/1234
@ -74,7 +75,8 @@ This is allowed:
```http ```http
GET /.versia/v0.6/entities/user/1234 GET /.versia/v0.6/entities/user/1234
Host: example.com Host: example.com
Accept: text/html
HTTP/1.1 301 Moved Permanently HTTP/1.1 301 Moved Permanently
Location: https://example.com/.versia/v0.6/entities/user/1234 Location: https://example.com/users/1234
``` ```

View file

@ -5,6 +5,58 @@ export const metadata = {
# Endpoints # Endpoints
## Well-known
<Warning>
This endpoint is exempt from the signature requirement. No signatures are required for requests or responses to it.
The following `Accept` headers are also allowed for requests to this endpoint:
- `application/jrd+json`
- `application/json`
</Warning>
<Row>
<Col>
<Properties name="Well-known">
<Property name="endpoint">
Must be `/.well-known/versia`.
</Property>
<Property name="method">
Must be `GET`.
</Property>
<Property name="response">
A small JSON object with a single attribute:
- `versions`: Supported Versia Protocol versions.
- Versions marked as "Working Draft X" are represented as `0.X`.
</Property>
</Properties>
</Col>
<Col sticky>
```http {{ 'title': 'Example request' }}
GET /.well-known/versia
Host: b.social
Accept: application/jrd+json
```
```http {{ 'title': 'Example response' }}
HTTP/1.1 200 OK
Content-Type: application/jrd+json
{
"versions": [
"0.6.0",
"0.5.0"
]
}
```
</Col>
</Row>
## Instance metadata ## Instance metadata
<Warning> <Warning>

View file

View file

@ -11,8 +11,10 @@ This page lists changes since Working Draft 3. {{ className: 'lead' }}
## Since WD 5 ## Since WD 5
- Added a new `content-type` for Versia entities: `application/vnd.versia+json`. - Added a new `content-type` for Versia entities: `application/vnd.versia+json`.
- Overhauled the Instance-to-Instance API to have clearly defined and namespaced endpoints, under `/.versia/v0.6/`, instead of letting implementations define their own endpoints.
- Removed per-User keypairs: now, only the instance keypair is used for signing. - Removed per-User keypairs: now, only the instance keypair is used for signing.
- Moved [Delegation](/extensions/delegation) to an extension - Moved [Delegation](/extensions/delegation) to an extension
- Changed the contents of the [Well-Known Versia Endpoint](/api/endpoints#well-known) to only list supported protocol versions.
- Modified how URIs and references to other entities are handled: - Modified how URIs and references to other entities are handled:
- The `uri` field has been removed from all entities. - The `uri` field has been removed from all entities.
- Every field that used to be a URI now uses that entity's `id` field. - Every field that used to be a URI now uses that entity's `id` field.

View file

@ -49,11 +49,32 @@ Accept: application/jrd+json
## Instance Discovery ## Instance Discovery
Instance metadata can be accessed by making a `GET` request to the instance's Versia metadata endpoint, documented in the [Endpoints](/api/endpoints#instance-metadata) document. Instance metadata can be accessed in two steps:
1. Making a `GET` request to the instance's [`/.well-known/versia` endpoint](/api/endpoints#well-known) to discover supported Versia Protocol versions.
2. Picking a protocol version to use, and then querying the instance metadata endpoint as documented in the [Endpoints](/api/endpoints#instance-metadata) document.
### Example ### Example
To discover the metadata of the instance `versia.social`, an instance would make a `GET` request to `https://versia.social/.versia/v0.6/instance`. To discover the metadata of the instance `versia.social`, an instance would first make a `GET` request to `https://versia.social/.well-known/versia`.
```http {{ 'title': 'Example Request' }}
GET /.well-known/versia HTTP/1.1
Accept: application/json
```
```jsonc {{ 'title': 'Example Response' }}
{
"versions": [
"0.6.0",
"0.5.0"
]
}
```
Then, we
- Pick version `0.6.0` to use
- Make a `GET` request to `https://versia.social/.versia/v0.6/instance`.
This endpoint will return an [InstanceMetadata](/entities/instance-metadata) entity. This endpoint will return an [InstanceMetadata](/entities/instance-metadata) entity.
@ -72,7 +93,8 @@ Accept: application/vnd.versia+json
}, },
"compatibility": { "compatibility": {
"versions": [ "versions": [
"0.5.0" "0.5.0",
"0.6.0"
], ],
"extensions": [ "extensions": [
"pub.versia:reactions", "pub.versia:reactions",

View file

@ -275,9 +275,6 @@ export const navigation: NavGroup[] = [
links: [ links: [
{ title: "Basics", href: "/api/basics" }, { title: "Basics", href: "/api/basics" },
{ title: "Endpoints", href: "/api/endpoints" }, { title: "Endpoints", href: "/api/endpoints" },
{ title: "Rate Limits", href: "/api/rate-limits" },
{ title: "Errors", href: "/api/errors" },
{ title: "HTML Redirects", href: "/api/html" },
], ],
}, },
{ {