fix: 📝 Update HTTP documentation

This commit is contained in:
Jesse Wierzbinski 2024-08-06 17:14:22 +02:00
parent df3514a297
commit 94149042fe
No known key found for this signature in database
2 changed files with 26 additions and 13 deletions

View file

@ -21,11 +21,14 @@ ALL kinds of HTTP requests/responses between instances **MUST** include a [Signa
<Property name="Content-Type" type="string" required={true}> <Property name="Content-Type" type="string" required={true}>
Must include `application/json; charset=utf-8`, if the request has a body. Must include `application/json; charset=utf-8`, if the request has a body.
</Property> </Property>
<Property name="Signature" type="string" required={false} typeLink="/signatures"> <Property name="X-Signature" type="string" required={false}>
Request signature, if the request is signed. See [Signatures](/signatures) for more information.
</Property> </Property>
<Property name="Date" type="UTC Time" required={true} typeLink="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Date"> <Property name="X-Signed-By" type="URI" required={false} typeLink="/types#uri">
Date and time of the request. See [Signatures](/signatures).
</Property>
<Property name="X-Nonce" type="string" required={false}>
See [Signatures](/signatures).
</Property> </Property>
<Property name="User-Agent" type="string" required={false}> <Property name="User-Agent" type="string" required={false}>
A string identifying the software making the request. A string identifying the software making the request.
@ -34,11 +37,12 @@ ALL kinds of HTTP requests/responses between instances **MUST** include a [Signa
</Col> </Col>
<Col sticky> <Col sticky>
```http {{ 'title': 'Example Request' }} ```http {{ 'title': 'Example Request' }}
POST /users/1/inbox HTTP/1.1 POST https://bob.com/users/1/inbox HTTP/1.1
Accept: application/json 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) User-Agent: CoolServer/1.0 (https://coolserver.com)
X-Signature: post /users/1/inbox a2ebc29eb6762a9164fbcffc9271e8a53562a5e725e7187ea7d88d03cbe59341 n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=
X-Signed-By: https://example.com/users/1
X-Nonce: a2ebc29eb6762a9164fbcffc9271e8a53562a5e725e7187ea7d88d03cbe59341
``` ```
</Col> </Col>
</Row> </Row>
@ -51,11 +55,14 @@ ALL kinds of HTTP requests/responses between instances **MUST** include a [Signa
<Property name="Content-Type" type="string" required={true}> <Property name="Content-Type" type="string" required={true}>
Must include `application/json; charset=utf-8`. Must include `application/json; charset=utf-8`.
</Property> </Property>
<Property name="Signature" type="string" required={false} typeLink="/signatures"> <Property name="X-Signature" type="string" required={false}>
Response signature, if the response is signed. See [Signatures](/signatures) for more information.
</Property> </Property>
<Property name="Date" type="UTC Time" required={true} typeLink="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Date"> <Property name="X-Signed-By" type="URI" required={false} typeLink="/types#uri">
Date and time of the response. See [Signatures](/signatures).
</Property>
<Property name="X-Nonce" type="string" required={false}>
See [Signatures](/signatures).
</Property> </Property>
</Properties> </Properties>
</Col> </Col>
@ -63,8 +70,9 @@ ALL kinds of HTTP requests/responses between instances **MUST** include a [Signa
```http {{ 'title': 'Example Response' }} ```http {{ 'title': 'Example Response' }}
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8 Content-Type: application/json; charset=utf-8
Date: Thu, 01 Jan 1970 00:00:00 GMT X-Signature: get /users/1/followers 8f872d4609d26819d03a7d60ce3db68f5b0dd5a80d5930260294f237e670ab76 YDA64iuZiGG847KPM+7BvnWKITyGyTwHbb6fVYwRx1I
Signature: keyId="https://example.com/users/1",algorithm="ed25519",headers="(request-target) host date digest",signature="..." X-Signed-By: https://example.com/users/1
X-Nonce: 8f872d4609d26819d03a7d60ce3db68f5b0dd5a80d5930260294f237e670ab76
``` ```
</Col> </Col>
</Row> </Row>

View file

@ -42,6 +42,11 @@ Where:
Sign this string using the user's private key. The resulting signature should be encoded in base64. Sign this string using the user's private key. The resulting signature should be encoded in base64.
Example:
```
post /notes a2ebc29eb6762a9164fbcffc9271e8a53562a5e725e7187ea7d88d03cbe59341 n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=
```
### Verifying the Signature ### Verifying the Signature
To verify a signature, the server must: To verify a signature, the server must: