docs/app/federation/http/page.mdx
2024-07-27 15:37:58 +02:00

78 lines
3.2 KiB
Plaintext

export const metadata = {
title: 'HTTP',
description:
'How Lysand uses the HTTP protocol for all communications between instances.',
}
# HTTP
Lysand uses the HTTP protocol for all communications between instances. HTTP requests must conform to certain standards to ensure compatibility between different implementations, as well as to ensure the security and integrity of the data being exchanged.
## Communication
ALL kinds of HTTP requests/responses between instances **MUST** include a [Signature](/signatures), signed with either the relevant [User](/entities/users)'s private key or the [Server Actor](/entities/server-actor)'s private key.
## Requests
<Row>
<Col>
<Properties>
<Property name="Accept" type="string" required={true}>
Must include `application/json`.
</Property>
<Property name="Content-Type" type="string" required={true}>
Must include `application/json; charset=utf-8`, if the request has a body.
</Property>
<Property name="Signature" type="string" required={false} typeLink="/signatures">
Request signature, if the request is signed.
</Property>
<Property name="Date" type="ISO8601" required={true}>
Date and time of the request.
</Property>
<Property name="User-Agent" type="string" required={false}>
A string identifying the software making the request.
</Property>
</Properties>
</Col>
<Col sticky>
```http {{ 'title': 'Example Request' }}
POST /users/1/inbox HTTP/1.1
Accept: application/json
Signature: keyId="https://example.com/users/1",algorithm="ed25519",headers="(request-target) host date digest",signature="..."
Date: Thu, 01 Jan 1970 00:00:00 GMT
User-Agent: CoolServer/1.0 (https://coolserver.com)
```
</Col>
</Row>
## Responses
<Row>
<Col>
<Properties>
<Property name="Content-Type" type="string" required={true}>
Must include `application/json; charset=utf-8`.
</Property>
<Property name="Signature" type="string" required={false} typeLink="/signatures">
Response signature, if the response is signed.
</Property>
<Property name="Date" type="ISO8601" required={true}>
Date and time of the response.
</Property>
<Property name="Cache-Control" type="string" required={false}>
Must include `no-store` on entities that can be edited directly without a `Patch`, such as `Users`.
**SHOULD** include a large `max-age` on entities that are not expected to change frequently, such as `Notes`, or CDN resources.
</Property>
</Properties>
</Col>
<Col sticky>
```http {{ 'title': 'Example Response' }}
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Thu, 01 Jan 1970 00:00:00 GMT
Signature: keyId="https://example.com/users/1",algorithm="ed25519",headers="(request-target) host date digest",signature="..."
Cache-Control: no-store
```
</Col>
</Row>