mirror of
https://github.com/cadmium-im/cadmium-docs-legacy.git
synced 2024-11-22 02:12:21 +00:00
Separate the extensions of the protocol errors and account login system into a separate CE documents
This commit is contained in:
parent
4963602bbd
commit
788daa8516
87
protocol-spec/account-login-by-username.md
Normal file
87
protocol-spec/account-login-by-username.md
Normal file
@ -0,0 +1,87 @@
|
||||
# Account login by username
|
||||
## Introduction
|
||||
This extension is intended for logging into user account on a server by username
|
||||
|
||||
## Message type identifiers
|
||||
- `profile:login`
|
||||
|
||||
## Error codes
|
||||
- 0: limit exceed
|
||||
- 1: user ID/password isn't valid
|
||||
|
||||
## Use cases
|
||||
*Request*:
|
||||
```json
|
||||
{
|
||||
"id": "abcd",
|
||||
"type": "profile:login",
|
||||
"to": "cadmium.org",
|
||||
"payload": {
|
||||
"username": "juliet",
|
||||
"password": "romeo1"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
*Response*:
|
||||
```json
|
||||
{
|
||||
"id": "abcd",
|
||||
"type": "profile:login",
|
||||
"from": "cadmium.org",
|
||||
"ok": true,
|
||||
"payload": {
|
||||
"authToken": "3b5135a5-aff5-4396-a629-a254f383e82f",
|
||||
"deviceID": "ABCDEFG"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
*<b>Error</b> response*:
|
||||
```json
|
||||
{
|
||||
"id": "abcd",
|
||||
"type": "profile:login",
|
||||
"from": "cadmium.org",
|
||||
"ok": false,
|
||||
"payload": {
|
||||
"errCode": 1,
|
||||
"errText": "Username/password isn't valid"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Business Rules
|
||||
None.
|
||||
|
||||
## JSON Schema
|
||||
**Payload**
|
||||
|
||||
- Request:
|
||||
```typescript
|
||||
interface LoginRequestPayload {
|
||||
/**
|
||||
* The username of account which user wants to login
|
||||
*/
|
||||
username: string,
|
||||
|
||||
/**
|
||||
* Password of new account
|
||||
*/
|
||||
password: string
|
||||
}
|
||||
```
|
||||
- Response:
|
||||
```typescript
|
||||
interface LoginResponsePayload {
|
||||
/**
|
||||
* Authentication token which required for various user actions (UUID)
|
||||
*/
|
||||
authToken: string,
|
||||
|
||||
/**
|
||||
* Identifier of new user device (created by this login action)
|
||||
*/
|
||||
deviceID: string
|
||||
}
|
||||
```
|
@ -4,10 +4,7 @@
|
||||
- [Transport](#transport)
|
||||
- [Entity ID](#entity-id)
|
||||
- [BaseMessage](#basemessage)
|
||||
- [Errors](#errors)
|
||||
- [User devices](#user-devices)
|
||||
- [Account registration/login](#account-registrationlogin)
|
||||
- [Login into account (by username)](#login-into-account-by-username)
|
||||
|
||||
## Transport
|
||||
For starting we simply use JSON + Websockets.
|
||||
@ -69,144 +66,6 @@ interface BaseMessage {
|
||||
}
|
||||
```
|
||||
|
||||
## Errors
|
||||
Mechanism of error processing included into protocol.
|
||||
Adds into type name `:error` postfix.
|
||||
|
||||
**Payload**:
|
||||
```typescript
|
||||
interface ErrorPayload {
|
||||
/**
|
||||
* Error code (defined in extensions, may be same per extensions)
|
||||
*/
|
||||
errCode: number,
|
||||
|
||||
/**
|
||||
* Explanation of error in human-readable view
|
||||
*/
|
||||
errText: string,
|
||||
|
||||
/**
|
||||
* Advanced error information (fields defined in extensions)
|
||||
*/
|
||||
errPayload: Map<K,V>
|
||||
}
|
||||
```
|
||||
|
||||
**Usecase**:
|
||||
|
||||
*Request*:
|
||||
```json
|
||||
{
|
||||
"id": "abcd",
|
||||
"type": "incorrectMessageType",
|
||||
"from": "@juliet@cadmium.im",
|
||||
"to": "cadmium.im",
|
||||
"payload": {
|
||||
"test": "test"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
*Response*:
|
||||
```json
|
||||
{
|
||||
"id": "abcd",
|
||||
"type": "incorrectMessageType:error",
|
||||
"from": "cadmium.im",
|
||||
"to": "@juliet@cadmium.im",
|
||||
"payload": {
|
||||
"errCode": 0,
|
||||
"errText": "Incorrect type of message (type isn't implemented in the server)",
|
||||
"errPayload": {}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## User devices
|
||||
`todo`
|
||||
|
||||
## Account registration/login
|
||||
|
||||
### Login into account (by username)
|
||||
**Description**: Login into user account on a server by username
|
||||
**Type**: `profile:login`
|
||||
**Payload**:
|
||||
- Request:
|
||||
```typescript
|
||||
interface LoginRequestPayload {
|
||||
/**
|
||||
* The username of account which user wants to login
|
||||
*/
|
||||
username: string,
|
||||
|
||||
/**
|
||||
* Password of new account
|
||||
*/
|
||||
password: string
|
||||
}
|
||||
```
|
||||
- Response:
|
||||
```typescript
|
||||
interface LoginResponsePayload {
|
||||
/**
|
||||
* Authentication token which required for various user actions (UUID)
|
||||
*/
|
||||
authToken: string,
|
||||
|
||||
/**
|
||||
* Identifier of new user device (created by this login action)
|
||||
*/
|
||||
deviceID: string
|
||||
}
|
||||
```
|
||||
|
||||
**Errors**:
|
||||
- 0: limit exceed
|
||||
- 1: user ID/password isn't valid
|
||||
|
||||
**Usecase**:
|
||||
|
||||
*Request*:
|
||||
```json
|
||||
{
|
||||
"id": "abcd",
|
||||
"type": "profile:login",
|
||||
"to": "cadmium.org",
|
||||
"payload": {
|
||||
"username": "juliet",
|
||||
"password": "romeo1"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
*Response*:
|
||||
```json
|
||||
{
|
||||
"id": "abcd",
|
||||
"type": "profile:login",
|
||||
"from": "cadmium.org",
|
||||
"ok": true,
|
||||
"payload": {
|
||||
"authToken": "3b5135a5-aff5-4396-a629-a254f383e82f",
|
||||
"deviceID": "ABCDEFG"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
*<b>Error</b> response*:
|
||||
```json
|
||||
{
|
||||
"id": "abcd",
|
||||
"type": "profile:login",
|
||||
"from": "cadmium.org",
|
||||
"ok": false,
|
||||
"payload": {
|
||||
"errCode": 1,
|
||||
"errText": "Username/password isn't valid"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Special business rules**: none.
|
||||
|
||||
|
58
protocol-spec/protocol-errors.md
Normal file
58
protocol-spec/protocol-errors.md
Normal file
@ -0,0 +1,58 @@
|
||||
# Protocol Errors
|
||||
## Introduction
|
||||
Mechanism of error processing included into protocol.
|
||||
Adds into any type ID `:error` postfix.
|
||||
|
||||
## Message type identifiers
|
||||
- `*:error`
|
||||
|
||||
## Use cases
|
||||
*Request*:
|
||||
```json
|
||||
{
|
||||
"id": "abcd",
|
||||
"type": "incorrectMessageType",
|
||||
"from": "@juliet@cadmium.im",
|
||||
"to": "cadmium.im",
|
||||
"payload": {
|
||||
"test": "test"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
*Response*:
|
||||
```json
|
||||
{
|
||||
"id": "abcd",
|
||||
"type": "incorrectMessageType:error",
|
||||
"from": "cadmium.im",
|
||||
"to": "@juliet@cadmium.im",
|
||||
"payload": {
|
||||
"errCode": 0,
|
||||
"errText": "Incorrect type of message (type isn't implemented in the server)",
|
||||
"errPayload": {}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## JSON Schema
|
||||
**Payload**
|
||||
|
||||
```typescript
|
||||
interface ErrorPayload {
|
||||
/**
|
||||
* Error code (defined in extensions, may be same per extensions)
|
||||
*/
|
||||
errCode: number,
|
||||
|
||||
/**
|
||||
* Explanation of error in human-readable view
|
||||
*/
|
||||
errText: string,
|
||||
|
||||
/**
|
||||
* Advanced error information (fields defined in extensions)
|
||||
*/
|
||||
errPayload: Map<K,V>
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user