Separate the extensions of the protocol errors and account login system into a separate CE documents

This commit is contained in:
ChronosX88 2019-12-15 20:21:43 +04:00
parent 4963602bbd
commit 788daa8516
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A
3 changed files with 145 additions and 141 deletions

View 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
}
```

View File

@ -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.

View 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>
}
```