From 5ac87b9a2acc14c042157d4ec5f31b58e983fb23 Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Thu, 16 Jul 2020 12:04:56 +0400 Subject: [PATCH] Slightly fix protocol error specs --- protocol-spec/account-login-by-username.md | 2 +- protocol-spec/account-registration.md | 2 +- protocol-spec/basic-request-ratelimit.md | 6 +- .../json-schema/BaseMessage.schema.json | 74 ------------------- .../json-schema/ProtocolError.schema.json | 43 ----------- protocol-spec/protocol-errors.md | 4 +- 6 files changed, 7 insertions(+), 124 deletions(-) delete mode 100644 protocol-spec/json-schema/BaseMessage.schema.json delete mode 100644 protocol-spec/json-schema/ProtocolError.schema.json diff --git a/protocol-spec/account-login-by-username.md b/protocol-spec/account-login-by-username.md index cd6f0d1..8457600 100644 --- a/protocol-spec/account-login-by-username.md +++ b/protocol-spec/account-login-by-username.md @@ -53,7 +53,7 @@ This extension is intended for logging into user account on a server by username "from": "cadmium.org", "ok": false, "payload": { - "errCode": "invalid_creds", + "errID": "invalid_creds", "errText": "Username/password isn't valid" } } diff --git a/protocol-spec/account-registration.md b/protocol-spec/account-registration.md index 4992d1e..3ef0e63 100644 --- a/protocol-spec/account-registration.md +++ b/protocol-spec/account-registration.md @@ -62,7 +62,7 @@ This extension is intended for creating user accounts on a server "from": "cadmium.org", "ok": false, "payload": { - "errCode": "id_exists", + "errID": "id_exists", "errText": "Username/email/msisdn already taken" } } diff --git a/protocol-spec/basic-request-ratelimit.md b/protocol-spec/basic-request-ratelimit.md index 840c5d6..ac420a8 100644 --- a/protocol-spec/basic-request-ratelimit.md +++ b/protocol-spec/basic-request-ratelimit.md @@ -34,10 +34,10 @@ None. "from": "cadmium.org", "ok": false, "payload": { - "errCode": "ratelimit_exceed", + "errID": "ratelimit_exceed", "errText": "Request ratelimit exceed! Please, try again later!", "errPayload": { - "retryAfter": 2 + "retryAfter": 1000 } } } @@ -61,7 +61,7 @@ None. ```typescript interface RatelimitExceedErrorPayload { /** - * How long after the client can retry the request (in seconds) + * How long after the client can retry the request (in millis) */ retryAfter: number } diff --git a/protocol-spec/json-schema/BaseMessage.schema.json b/protocol-spec/json-schema/BaseMessage.schema.json deleted file mode 100644 index 343b1db..0000000 --- a/protocol-spec/json-schema/BaseMessage.schema.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "definitions": {}, - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "urn:cadmium:0", - "type": "object", - "title": "Base Message Schema", - "required": [ - "id", - "type", - "from", - "to", - "payload" - ], - "additionalProperties": false, - "properties": { - "id": { - "$id": "#/properties/id", - "type": "string", - "title": "id", - "description": "Message identifier (used to track the request-response chain)", - "examples": [ - "abcd" - ] - }, - "type": { - "$id": "#/properties/type", - "type": "string", - "title": "type", - "description": "Type of message (used to determine which extension this message belongs to)", - "examples": [ - "profile:register", - "profile:login", - "incorrectMessageType:error" - ] - }, - "from": { - "$id": "#/properties/from", - "type": "string", - "title": "from", - "description": "From which entity this message is send. May be set to \"anonymous\" value, if action doesn't require authorization. This is EntityID", - "examples": [ - "396277b7dcd0f1173f2007baa604de7593529cc3fbf335fb7924851cb25c1fdf", - "@juliet@396277b7dcd0f1173f2007baa604de7593529cc3fbf335fb7924851cb25c1fdf", - "#chpok@b9966d89028b120145dad38961bed0b3b2eac0a2915c0bb1665ffcc1586f6f59", - "anonymous" - ] - }, - "to": { - "$id": "#/properties/to", - "type": "string", - "title": "to", - "description": "Message recipient. This is Entity ID.", - "examples": [ - "@juliet@02a6f23250868e903ff62e99e664a5717e945ca8153bf0ebc4f505cbe3a0860c", - "#white_house_garden@8baef2426dc6a92e16d39d79d90ae6d5a0080aaeccc5f02f1e83a959bc4d0be7", - "%phone:1234567890@6dfea40d98f71b3191f94c31af887a00eaeef2fe3501226e3fbb302fc5269eec", - "@romeo@cadmium.im" - ] - }, - "payload": { - "$id": "#/properties/payload", - "type": "object", - "title": "payload", - "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" - } - } - } - \ No newline at end of file diff --git a/protocol-spec/json-schema/ProtocolError.schema.json b/protocol-spec/json-schema/ProtocolError.schema.json deleted file mode 100644 index e400f21..0000000 --- a/protocol-spec/json-schema/ProtocolError.schema.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "definitions": {}, - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "urn:cadmium:1", - "type": "object", - "title": "Protocol Error Schema", - "required": [ - "errCode", - "errText" - ], - "additionalProperties": false, - "properties": { - "errCode": { - "$id": "#/properties/errCode", - "type": "integer", - "title": "Error Code", - "description": "Error code (defined in extensions, may be same per extensions)", - "examples": [ - 0, - 1, - 2, - 3, - 4 - ] - }, - "errText": { - "$id": "#/properties/errText", - "type": "string", - "title": "Error Text", - "description": "Explanation of error in human-readable view", - "examples": [ - "Incorrect type of message (type isn't implemented in the server)", - "Rate-limit exceed" - ] - }, - "errPayload": { - "$id": "#/properties/errPayload", - "type": "object", - "title": "Error Payload", - "description": "Advanced error information (fields defined in extensions)" - } - } - } \ No newline at end of file diff --git a/protocol-spec/protocol-errors.md b/protocol-spec/protocol-errors.md index 116a24e..5b2b5e4 100644 --- a/protocol-spec/protocol-errors.md +++ b/protocol-spec/protocol-errors.md @@ -35,7 +35,7 @@ None. "to": "@juliet@cadmium.im", "ok": false, "payload": { - "errCode": 0, + "errID": "unhandled", "errText": "Incorrect type of message (type isn't implemented in the server)", "errPayload": {} } @@ -51,7 +51,7 @@ interface ErrorPayload { /** * Error identifier (defined in extensions, maybe same per extensions) */ - errId: string, + errID: string, /** * Explanation of error in human-readable view