diff --git a/protocol-spec/account-login-by-username.md b/protocol-spec/account-login-by-username.md new file mode 100644 index 0000000..1fd024a --- /dev/null +++ b/protocol-spec/account-login-by-username.md @@ -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" + } +} +``` + +*Error 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 +} +``` \ No newline at end of file diff --git a/protocol-spec/core.md b/protocol-spec/core.md index 334cda3..b830602 100644 --- a/protocol-spec/core.md +++ b/protocol-spec/core.md @@ -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 -} -``` - -**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" - } -} -``` - -*Error 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. - diff --git a/protocol-spec/protocol-errors.md b/protocol-spec/protocol-errors.md new file mode 100644 index 0000000..a9c52c3 --- /dev/null +++ b/protocol-spec/protocol-errors.md @@ -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 +} +``` \ No newline at end of file