mirror of
https://github.com/cadmium-im/cadmium-docs-legacy.git
synced 2024-11-09 20:21:03 +00:00
Merge branch 'master' into SPEC-2
This commit is contained in:
commit
d42d86eb8e
@ -1,14 +1,18 @@
|
|||||||
# The Sections of a Cadmium Protocol Proposal (CPP) document
|
# The Sections of a Cadmium Protocol Proposal (CPP) document
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
The introduction to a CPP document should contain description of the extension and example of problems which this extension can solve.
|
The introduction to a CPP document should contain description of the extension and example of problems which this extension can solve.
|
||||||
|
|
||||||
## Message type identifiers
|
## Message type identifiers
|
||||||
|
|
||||||
In this section, specify the identifiers of the new types of protocol messages (which are introduced by the extension)
|
In this section, specify the identifiers of the new types of protocol messages (which are introduced by the extension)
|
||||||
|
|
||||||
## Glossary
|
## Glossary
|
||||||
|
|
||||||
If your CE document uses terms that may not be familiar to the reader, please define them in this section.
|
If your CE document uses terms that may not be familiar to the reader, please define them in this section.
|
||||||
|
|
||||||
## Use Cases
|
## Use Cases
|
||||||
|
|
||||||
It is recommended that document authors structure their proposals according to the use cases that the proposal will address. We have found that use cases force authors to focus on functionality rather than "protocol for the sake of protocol". It is also helpful to sort use cases by actor. Include one subsection for each use case.
|
It is recommended that document authors structure their proposals according to the use cases that the proposal will address. We have found that use cases force authors to focus on functionality rather than "protocol for the sake of protocol". It is also helpful to sort use cases by actor. Include one subsection for each use case.
|
||||||
|
|
||||||
When writing use cases and the associated protocols, make sure to:
|
When writing use cases and the associated protocols, make sure to:
|
||||||
@ -17,7 +21,8 @@ When writing use cases and the associated protocols, make sure to:
|
|||||||
* Describe the expected behavior of Cadmium clients, servers, and components when using this protocol.
|
* Describe the expected behavior of Cadmium clients, servers, and components when using this protocol.
|
||||||
* Include lots of protocol examples.
|
* Include lots of protocol examples.
|
||||||
|
|
||||||
*Example 1. An Example from Shakespeare*
|
*Example 1. An Example from Shakespeare*:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "abcd",
|
"id": "abcd",
|
||||||
@ -29,31 +34,41 @@ When writing use cases and the associated protocols, make sure to:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Error Codes
|
|
||||||
If your proposal defines a number of error and status codes, it is a good idea to include a table of all the codes defined in your document.
|
## Errors
|
||||||
|
|
||||||
|
If your proposal defines a number of error and error identifiers, it is a good idea to include a table of all the identifiers defined in your document.
|
||||||
|
|
||||||
## Business Rules
|
## Business Rules
|
||||||
You may want to include a section describing various business rules (essentially, a variety of MUSTs, SHOULDs, and MAYs regarding application behavior). This is not required but can be helpful to implementers.
|
|
||||||
|
You may want to include a section describing various business rules (essentially, a variety of MUSTs, SHOULDs, and MAYs regarding application behavior). This section is not required but can be helpful to implementers.
|
||||||
|
|
||||||
## Implementation Notes
|
## Implementation Notes
|
||||||
|
|
||||||
You may want to include a section devoted to implementation notes. Again, this is not required but can be helpful to implementers.
|
You may want to include a section devoted to implementation notes. Again, this is not required but can be helpful to implementers.
|
||||||
|
|
||||||
## Internationalization Considerations
|
## Internationalization Considerations
|
||||||
|
|
||||||
If there are any internationalization or localization issues related to your proposal, define them in this optional section.
|
If there are any internationalization or localization issues related to your proposal, define them in this optional section.
|
||||||
|
|
||||||
## Security Considerations
|
## Security Considerations
|
||||||
|
|
||||||
Your proposal MUST include a section entitled "Security Considerations". Even if there are no security features or concerns related to your proposal, you MUST note that fact. For helpful guidelines, refer to RFC 3552.
|
Your proposal MUST include a section entitled "Security Considerations". Even if there are no security features or concerns related to your proposal, you MUST note that fact. For helpful guidelines, refer to RFC 3552.
|
||||||
|
|
||||||
## JSON Schema
|
## JSON Schema
|
||||||
|
|
||||||
An JSON Schema is required in order for protocols to be approved by the Cadmium Developers. The Cadmium Developers team can assist you in defining an JSON Schema for the protocol you are proposing. Also you can define your schema as TypeScript interfaces, this is also allowed.
|
An JSON Schema is required in order for protocols to be approved by the Cadmium Developers. The Cadmium Developers team can assist you in defining an JSON Schema for the protocol you are proposing. Also you can define your schema as TypeScript interfaces, this is also allowed.
|
||||||
|
|
||||||
## Acknowledgements (optional)
|
## Acknowledgements (optional)
|
||||||
|
|
||||||
Most CE documents end with a section thanking non-authors who have made significant contributions or who have provided feedback regarding the specification.
|
Most CE documents end with a section thanking non-authors who have made significant contributions or who have provided feedback regarding the specification.
|
||||||
|
|
||||||
# Cadmium Extension Styleguide
|
## Cadmium Extension Styleguide
|
||||||
|
|
||||||
CE document are written in English. It is not expected that you will be a fine prose writer, but try to write in a clear, easily-understood fashion.
|
CE document are written in English. It is not expected that you will be a fine prose writer, but try to write in a clear, easily-understood fashion.
|
||||||
|
|
||||||
## Code Examples
|
### Code Examples
|
||||||
|
|
||||||
To show the hierarchy of JSON objects, indent two spaces for every level.
|
To show the hierarchy of JSON objects, indent two spaces for every level.
|
||||||
|
|
||||||
If an element possesses a large number of attributes, include a line break before each attribute and indent them so that they are vertically aligned for readability.
|
If an element possesses a large number of attributes, include a line break before each attribute and indent them so that they are vertically aligned for readability.
|
||||||
@ -61,6 +76,7 @@ If an element possesses a large number of attributes, include a line break befor
|
|||||||
If the JSON data of an element is long, include line breaks and indent by two spaces.
|
If the JSON data of an element is long, include line breaks and indent by two spaces.
|
||||||
|
|
||||||
*Example*:
|
*Example*:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "abcd",
|
"id": "abcd",
|
||||||
@ -76,14 +92,19 @@ If the JSON data of an element is long, include line breaks and indent by two sp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Some examples include strings that are the output of a hashing algorithm such as SHA-1 or SHA-256. An easy way to generate these is to use the OpenSSL "dgst" command to generate the hash. For example, the following command will generate the SHA-1 hash `a6cf4baabcefb63189a1a1c56158aa431990bba9`:
|
Some examples include strings that are the output of a hashing algorithm such as SHA-1 or SHA-256. An easy way to generate these is to use the OpenSSL "dgst" command to generate the hash. For example, the following command will generate the SHA-1 hash `a6cf4baabcefb63189a1a1c56158aa431990bba9`:
|
||||||
```
|
|
||||||
|
```bash
|
||||||
echo -n '@juliet@396277b7dcd0f1173f2007baa604de7593529cc3fbf335fb7924851cb25c1fdf' | openssl dgst -hex -sha1
|
echo -n '@juliet@396277b7dcd0f1173f2007baa604de7593529cc3fbf335fb7924851cb25c1fdf' | openssl dgst -hex -sha1
|
||||||
```
|
```
|
||||||
|
|
||||||
Some examples include strings that are encoded using Base64. An easy way to generate these is to use the OpenSSL "enc" command to generate the base64-encoded equivalent. For example, the following command will generate the base64-encoded string `QGp1bGlldEAzOTYyNzdiN2RjZDBmMTE3M2YyMDA3YmFhNjA0ZGU3NTkzNTI5Y2MzZmJmMzM1ZmI3OTI0ODUxY2IyNWMxZmRm`:
|
Some examples include strings that are encoded using Base64. An easy way to generate these is to use the OpenSSL "enc" command to generate the base64-encoded equivalent. For example, the following command will generate the base64-encoded string `QGp1bGlldEAzOTYyNzdiN2RjZDBmMTE3M2YyMDA3YmFhNjA0ZGU3NTkzNTI5Y2MzZmJmMzM1ZmI3OTI0ODUxY2IyNWMxZmRm`:
|
||||||
```
|
|
||||||
|
```bash
|
||||||
echo -n '@juliet@396277b7dcd0f1173f2007baa604de7593529cc3fbf335fb7924851cb25c1fdf' | openssl enc -nopad -base64
|
echo -n '@juliet@396277b7dcd0f1173f2007baa604de7593529cc3fbf335fb7924851cb25c1fdf' | openssl enc -nopad -base64
|
||||||
```
|
```
|
||||||
## Conformance Terms
|
|
||||||
|
### Conformance Terms
|
||||||
|
|
||||||
Conformance terms (e.g,, "MUST" and "SHOULD") are specified in RFC 2119. Use them. When such terms are not in ALL CAPS, the special conformance sense does not apply (although it is preferable to use terms such as 'might' instead of 'may' and 'ought' instead of 'should').
|
Conformance terms (e.g,, "MUST" and "SHOULD") are specified in RFC 2119. Use them. When such terms are not in ALL CAPS, the special conformance sense does not apply (although it is preferable to use terms such as 'might' instead of 'may' and 'ought' instead of 'should').
|
@ -1,16 +1,22 @@
|
|||||||
# Account login by username
|
# Account login by username
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
This extension is intended for logging into user account on a server by username
|
This extension is intended for logging into user account on a server by username
|
||||||
|
|
||||||
## Message type identifiers
|
## Message type identifiers
|
||||||
|
|
||||||
- `profile:login`
|
- `profile:login`
|
||||||
|
|
||||||
## Error codes
|
## Errors
|
||||||
- 0: limit exceed
|
|
||||||
- 1: user ID/password isn't valid
|
- Ratelimit system: enabled
|
||||||
|
- `invalid_creds`: user ID/password isn't valid
|
||||||
|
|
||||||
## Use cases
|
## Use cases
|
||||||
*Request*:
|
|
||||||
|
- Request:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "abcd",
|
"id": "abcd",
|
||||||
@ -23,7 +29,8 @@ This extension is intended for logging into user account on a server by username
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
*Response*:
|
- Response:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "abcd",
|
"id": "abcd",
|
||||||
@ -37,7 +44,8 @@ This extension is intended for logging into user account on a server by username
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
*<b>Error</b> response*:
|
- Error response:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "abcd",
|
"id": "abcd",
|
||||||
@ -45,40 +53,51 @@ This extension is intended for logging into user account on a server by username
|
|||||||
"from": "cadmium.org",
|
"from": "cadmium.org",
|
||||||
"ok": false,
|
"ok": false,
|
||||||
"payload": {
|
"payload": {
|
||||||
"errCode": 1,
|
"errCode": "invalid_creds",
|
||||||
"errText": "Username/password isn't valid"
|
"errText": "Username/password isn't valid"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Business Rules
|
## Business Rules
|
||||||
|
|
||||||
None.
|
None.
|
||||||
|
|
||||||
## JSON Schema
|
## JSON Schema
|
||||||
**Payload**
|
|
||||||
|
### Payload
|
||||||
|
|
||||||
- Request:
|
- Request:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
interface LoginRequestPayload {
|
interface LoginRequestPayload {
|
||||||
/**
|
/**
|
||||||
* The username of account which user wants to login
|
* The username of account which user wants to login (can be omit if we set thirdPID)
|
||||||
*/
|
*/
|
||||||
username: string,
|
username: string,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Third party ID which have user (can be omit if we set username)
|
||||||
|
*/
|
||||||
|
thirdPID: string,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Password of new account
|
* Password of new account
|
||||||
*/
|
*/
|
||||||
password: string
|
password: string
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- Response:
|
- Response:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
interface LoginResponsePayload {
|
interface LoginResponsePayload {
|
||||||
/**
|
/**
|
||||||
* Authentication token which required for various user actions (UUID)
|
* Authentication token which required for various user actions (static SHA256 hash string from 4096 random characters)
|
||||||
*/
|
*/
|
||||||
authToken: string,
|
authToken: string,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifier of new user device (created by this login action)
|
* Identifier of new user device (created by this login action)
|
||||||
*/
|
*/
|
||||||
|
@ -1,17 +1,27 @@
|
|||||||
# Account registration
|
# Account registration
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
This extension is intended for creating user accounts on a server
|
This extension is intended for creating user accounts on a server
|
||||||
|
|
||||||
## Message type identifiers
|
## Message type identifiers
|
||||||
|
|
||||||
- `profile:register`
|
- `profile:register`
|
||||||
|
|
||||||
## Error codes
|
## Errors
|
||||||
- 0: limit exceed
|
|
||||||
- 1: username/third party ID already taken
|
- Ratelimit system: enabled
|
||||||
- 2: registration isn't allowed on a server
|
- `id_exists`: username/third party ID already taken
|
||||||
|
- `reg_disabled`: registration isn't allowed on a server
|
||||||
|
|
||||||
## Use cases
|
## Use cases
|
||||||
- Request:
|
|
||||||
|
### Basic registration flow
|
||||||
|
|
||||||
|
`// TODO: introduce email/msisdn confirmation which prevents spam attacks`
|
||||||
|
|
||||||
|
- Client:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "abcd",
|
"id": "abcd",
|
||||||
@ -23,12 +33,14 @@ This extension is intended for creating user accounts on a server
|
|||||||
{"type":"email", "value":"juliet@capulett.com"},
|
{"type":"email", "value":"juliet@capulett.com"},
|
||||||
{"type":"msisdn", "value":"+1234567890"},
|
{"type":"msisdn", "value":"+1234567890"},
|
||||||
],
|
],
|
||||||
"password": "romeo1"
|
"password": "romeo1",
|
||||||
|
"loginOnSuccess": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- Response:
|
- Server:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "abcd",
|
"id": "abcd",
|
||||||
@ -41,7 +53,8 @@ This extension is intended for creating user accounts on a server
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
*<b>Error</b> response*:
|
- Error response:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "abcd",
|
"id": "abcd",
|
||||||
@ -49,25 +62,28 @@ This extension is intended for creating user accounts on a server
|
|||||||
"from": "cadmium.org",
|
"from": "cadmium.org",
|
||||||
"ok": false,
|
"ok": false,
|
||||||
"payload": {
|
"payload": {
|
||||||
"errCode": 1,
|
"errCode": "id_exists",
|
||||||
"errText": "{Username/email/msisdn} already taken"
|
"errText": "Username/email/msisdn already taken"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Business Rules
|
## Business Rules
|
||||||
|
|
||||||
None.
|
None.
|
||||||
|
|
||||||
## JSON Schema
|
## JSON Schema
|
||||||
**Payload**
|
|
||||||
|
### Payload
|
||||||
|
|
||||||
- Request:
|
- Request:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
interface RegistrationRequestPayload {
|
interface RegistrationRequestPayload {
|
||||||
/**
|
/**
|
||||||
* The username that the user wants to register
|
* The username that the user wants to register
|
||||||
*/
|
*/
|
||||||
username: string,
|
username?: string,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of user third party IDs (email and/or MSISDN)
|
* Array of user third party IDs (email and/or MSISDN)
|
||||||
@ -77,7 +93,12 @@ interface RegistrationRequestPayload {
|
|||||||
/**
|
/**
|
||||||
* Password of new account
|
* Password of new account
|
||||||
*/
|
*/
|
||||||
password: string
|
password: string,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Login to freshly created user account when registration will be completed
|
||||||
|
*/
|
||||||
|
loginOnSuccess: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ThirdPartyID {
|
interface ThirdPartyID {
|
||||||
@ -92,12 +113,19 @@ interface ThirdPartyID {
|
|||||||
value: string
|
value: string
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- Response:
|
- Response:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
interface RegistrationResponsePayload {
|
interface RegistrationResponsePayload {
|
||||||
/**
|
/**
|
||||||
* ID of user (Username in priority. If we haven't username, then we put to this field one of user's third party IDs)
|
* ID of user (Username in priority. If we haven't username, then we put to this field one of user's third party IDs)
|
||||||
*/
|
*/
|
||||||
userID: EntityID
|
userID: EntityID,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Property with login payload (can be omit if property loginOnSuccess wasn't indicated true in RegistrationRequestPayload)
|
||||||
|
*/
|
||||||
|
loginPayload?: LoginResponsePayload
|
||||||
}
|
}
|
||||||
```
|
```
|
68
protocol-spec/basic-request-ratelimit.md
Normal file
68
protocol-spec/basic-request-ratelimit.md
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
# Basic request ratelimit system
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
This extension is intended to limit the number of requests from clients per unit of time. It is based on Protocol Errors extension.
|
||||||
|
|
||||||
|
## Message type identifiers
|
||||||
|
|
||||||
|
None.
|
||||||
|
|
||||||
|
## Use cases
|
||||||
|
|
||||||
|
- Client:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "abcd",
|
||||||
|
"type": "profile:register",
|
||||||
|
"to": "cadmium.org",
|
||||||
|
"payload": {
|
||||||
|
"username": "spam_spam_spam",
|
||||||
|
"thirdPIDs": [],
|
||||||
|
"password": "spam"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- Server:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "abcd",
|
||||||
|
"type": "profile:register",
|
||||||
|
"from": "cadmium.org",
|
||||||
|
"ok": false,
|
||||||
|
"payload": {
|
||||||
|
"errCode": "ratelimit_exceed",
|
||||||
|
"errText": "Request ratelimit exceed! Please, try again later!",
|
||||||
|
"errPayload": {
|
||||||
|
"retryAfter": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Errors
|
||||||
|
|
||||||
|
### Global errors
|
||||||
|
|
||||||
|
- `ratelimit_exceed`
|
||||||
|
|
||||||
|
## Business Rules
|
||||||
|
|
||||||
|
- Server MUST count number of requests per unit of time and drop new requests after specified number of made requests with Protocol Error message.
|
||||||
|
- Number of requests and used unit of time SHOULD be configurable on server
|
||||||
|
|
||||||
|
## JSON Schema
|
||||||
|
|
||||||
|
### Error payload
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface RatelimitExceedErrorPayload {
|
||||||
|
/**
|
||||||
|
* How long after the client can retry the request (in seconds)
|
||||||
|
*/
|
||||||
|
retryAfter: number
|
||||||
|
}
|
||||||
|
```
|
@ -3,35 +3,46 @@
|
|||||||
- [Protocol Core](#protocol-core)
|
- [Protocol Core](#protocol-core)
|
||||||
- [Transport](#transport)
|
- [Transport](#transport)
|
||||||
- [Entity ID](#entity-id)
|
- [Entity ID](#entity-id)
|
||||||
|
- [Server-part](#server-part)
|
||||||
|
- [Username/Room alias/RoomID](#usernameroom-aliasroomid)
|
||||||
|
- [Special business rules](#special-business-rules)
|
||||||
- [BaseMessage](#basemessage)
|
- [BaseMessage](#basemessage)
|
||||||
|
|
||||||
## Transport
|
## Transport
|
||||||
|
|
||||||
For starting we simply use JSON + Websockets.
|
For starting we simply use JSON + Websockets.
|
||||||
|
|
||||||
## Entity ID
|
## Entity ID
|
||||||
* Room alias: `#<roomAlias>@<serverpart>`
|
|
||||||
* Username: `@<username>@<serverpart>`
|
|
||||||
* User ID with any 3PID: `%<type>:<data>@<serverpart>`
|
|
||||||
* Currently supported only following types: `email` and `msisdn`.
|
|
||||||
* Raw User ID: `@<UUID>@<serverpart>`
|
|
||||||
* Message ID: `&<uuid>@<serverpart (from which server the message was sent)>`
|
|
||||||
* Room ID: `!<roomID>@<serverpart>`
|
|
||||||
* Single server-part: `<serverpart>`
|
|
||||||
|
|
||||||
**Server-part**:
|
- Room alias: `#<roomAlias>@<serverpart>`
|
||||||
|
- Username: `@<username>@<serverpart>`
|
||||||
|
- User ID with any 3PID: `%<type>:<data>@<serverpart>`
|
||||||
|
- Currently supported only following types: `email` and `msisdn`.
|
||||||
|
- Raw User ID: `@<UUID>@<serverpart>`
|
||||||
|
- Message ID: `&<uuid>@<serverpart (of source server)>`
|
||||||
|
- Room ID: `!<roomID>@<serverpart>`
|
||||||
|
- Single server-part: `<serverpart>`
|
||||||
|
|
||||||
|
### Server-part
|
||||||
|
|
||||||
- hostname: `IPv4 / [IPv6] / dns-domain:<port (1-65535)>` (for end-users use)
|
- hostname: `IPv4 / [IPv6] / dns-domain:<port (1-65535)>` (for end-users use)
|
||||||
- server ID: static SHA256 hash string from 4096 characters (for internal protocol use)
|
- server ID: static SHA256 hash string from 4096 characters (for internal protocol use)
|
||||||
|
|
||||||
**Username/Room alias/RoomID** - MUST NOT be empty, and MUST contain only the characters `a-z`, `0-9`, `.`, `_`, `=`, `-`, and `/`.
|
### Username/Room alias/RoomID
|
||||||
|
|
||||||
|
MUST NOT be empty, and MUST contain only the characters `a-z`, `0-9`, `.`, `_`, `=`, `-`, and `/`.
|
||||||
|
|
||||||
|
### Special business rules
|
||||||
|
|
||||||
**Special business rules**:
|
|
||||||
- RoomID SHOULD be UUID identifier.
|
- RoomID SHOULD be UUID identifier.
|
||||||
- Servers MUST use server ID in internal purposes instead of normal server-part with hostname. Only end-users MUST use normal server-part with hostname. This is done for easy multi-domain serving.
|
- Servers MUST use server ID in internal purposes instead of normal server-part with hostname. Only end-users MUST use normal server-part with hostname. This is done for easy multi-domain serving.
|
||||||
|
|
||||||
## BaseMessage
|
## BaseMessage
|
||||||
|
|
||||||
BaseMessage is a basic message model, basis of the whole protocol. It is used for a very easy protocol extension process.
|
BaseMessage is a basic message model, basis of the whole protocol. It is used for a very easy protocol extension process.
|
||||||
|
|
||||||
BaseMessage scheme:
|
BaseMessage scheme:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
interface BaseMessage {
|
interface BaseMessage {
|
||||||
/**
|
/**
|
||||||
@ -54,10 +65,15 @@ interface BaseMessage {
|
|||||||
to: EntityID,
|
to: EntityID,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operation success indicator (used to determine if the error happened while processing request)
|
* Operation success indicator (used to determine if the error happened while processing request) - MUST be only in response from server
|
||||||
*/
|
*/
|
||||||
ok: boolean,
|
ok: boolean,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authentication token string (can be omit if the action does not require user authentication) - MUST be only in request messages from client
|
||||||
|
*/
|
||||||
|
authToken?: string,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message payload (used to store extra information in message, list of permissible fields in the payload depends on "type" field)
|
* Message payload (used to store extra information in message, list of permissible fields in the payload depends on "type" field)
|
||||||
*/
|
*/
|
||||||
|
@ -62,6 +62,12 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "payload",
|
"title": "payload",
|
||||||
"description": "Message payload (used to store extra information in message, list of permissible fields in the payload depends on \"type\" field)"
|
"description": "Message payload (used to store extra information in message, list of permissible fields in the payload depends on \"type\" field)"
|
||||||
|
},
|
||||||
|
"ok": {
|
||||||
|
"$id": "#/properties/ok",
|
||||||
|
"type": "boolean",
|
||||||
|
"title": "ok",
|
||||||
|
"description": "Indicating whether request have an error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
# Protocol Errors
|
# Protocol Errors
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
Mechanism of error processing included into protocol.
|
Mechanism of error processing included into protocol.
|
||||||
Adds into any type ID `:error` postfix.
|
Adds into any response message `ok` variable. If `ok` is true - we have no errors, if `ok` is false - we have an error.
|
||||||
|
|
||||||
## Message type identifiers
|
## Message type identifiers
|
||||||
- `*:error`
|
|
||||||
|
None.
|
||||||
|
|
||||||
## Use cases
|
## Use cases
|
||||||
|
|
||||||
*Request*:
|
*Request*:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "abcd",
|
"id": "abcd",
|
||||||
@ -21,12 +26,14 @@ Adds into any type ID `:error` postfix.
|
|||||||
```
|
```
|
||||||
|
|
||||||
*Response*:
|
*Response*:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "abcd",
|
"id": "abcd",
|
||||||
"type": "incorrectMessageType:error",
|
"type": "incorrectMessageType",
|
||||||
"from": "cadmium.im",
|
"from": "cadmium.im",
|
||||||
"to": "@juliet@cadmium.im",
|
"to": "@juliet@cadmium.im",
|
||||||
|
"ok": false,
|
||||||
"payload": {
|
"payload": {
|
||||||
"errCode": 0,
|
"errCode": 0,
|
||||||
"errText": "Incorrect type of message (type isn't implemented in the server)",
|
"errText": "Incorrect type of message (type isn't implemented in the server)",
|
||||||
@ -36,14 +43,15 @@ Adds into any type ID `:error` postfix.
|
|||||||
```
|
```
|
||||||
|
|
||||||
## JSON Schema
|
## JSON Schema
|
||||||
**Payload**
|
|
||||||
|
### Payload
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
interface ErrorPayload {
|
interface ErrorPayload {
|
||||||
/**
|
/**
|
||||||
* Error code (defined in extensions, may be same per extensions)
|
* Error identifier (defined in extensions, maybe same per extensions)
|
||||||
*/
|
*/
|
||||||
errCode: number,
|
errId: string,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Explanation of error in human-readable view
|
* Explanation of error in human-readable view
|
||||||
|
Loading…
Reference in New Issue
Block a user