feat: add IRC-style message protocol JSON schemas (draft 2020-12)
Add JSON Schema definitions for all message types: - Base message envelope (message.schema.json) - C2S: PRIVMSG, NOTICE, JOIN, PART, QUIT, NICK, MODE, TOPIC, KICK, PING, PUBKEY - S2C: named commands + numeric reply codes (001, 002, 322, 353, 366, 372, 375, 376, 401, 403, 433) - S2S: RELAY, LINK, UNLINK, SYNC, PING, PONG - Schema index (schema/README.md) All messages use IRC command names and numeric codes from RFC 1459/2812. Bodies are always objects or arrays (never raw strings) to support deterministic canonicalization (RFC 8785 JCS) and message signing.
This commit is contained in:
23
schema/commands/JOIN.json
Normal file
23
schema/commands/JOIN.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/commands/JOIN.json",
|
||||
"title": "JOIN",
|
||||
"description": "Join a channel. C2S: request to join. S2C: notification that a user joined. RFC 1459 §4.2.1.",
|
||||
"$ref": "../message.json",
|
||||
"properties": {
|
||||
"command": { "const": "JOIN" },
|
||||
"from": {
|
||||
"type": "string",
|
||||
"description": "Nick that joined (S2C only)."
|
||||
},
|
||||
"to": {
|
||||
"type": "string",
|
||||
"description": "Channel name.",
|
||||
"pattern": "^#[a-zA-Z0-9_-]+$"
|
||||
}
|
||||
},
|
||||
"required": ["command", "to"],
|
||||
"examples": [
|
||||
{ "command": "JOIN", "from": "alice", "to": "#general" }
|
||||
]
|
||||
}
|
||||
23
schema/commands/NOTICE.json
Normal file
23
schema/commands/NOTICE.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/commands/NOTICE.json",
|
||||
"title": "NOTICE",
|
||||
"description": "Send a notice. Like PRIVMSG but must not trigger automatic replies. RFC 1459 §4.4.2.",
|
||||
"$ref": "../message.json",
|
||||
"properties": {
|
||||
"command": { "const": "NOTICE" },
|
||||
"from": { "type": "string" },
|
||||
"to": {
|
||||
"type": "string",
|
||||
"description": "Target: #channel, nick, or * (global)."
|
||||
},
|
||||
"body": {
|
||||
"type": "string",
|
||||
"description": "Notice text."
|
||||
}
|
||||
},
|
||||
"required": ["command", "to", "body"],
|
||||
"examples": [
|
||||
{ "command": "NOTICE", "from": "server.example.com", "to": "*", "body": "Server restarting in 5 minutes" }
|
||||
]
|
||||
}
|
||||
27
schema/commands/PART.json
Normal file
27
schema/commands/PART.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/commands/PART.json",
|
||||
"title": "PART",
|
||||
"description": "Leave a channel. C2S: request to leave. S2C: notification that a user left. RFC 1459 §4.2.2.",
|
||||
"$ref": "../message.json",
|
||||
"properties": {
|
||||
"command": { "const": "PART" },
|
||||
"from": {
|
||||
"type": "string",
|
||||
"description": "Nick that left (S2C only)."
|
||||
},
|
||||
"to": {
|
||||
"type": "string",
|
||||
"description": "Channel name.",
|
||||
"pattern": "^#[a-zA-Z0-9_-]+$"
|
||||
},
|
||||
"body": {
|
||||
"type": "string",
|
||||
"description": "Optional part reason."
|
||||
}
|
||||
},
|
||||
"required": ["command", "to"],
|
||||
"examples": [
|
||||
{ "command": "PART", "from": "alice", "to": "#general", "body": "later" }
|
||||
]
|
||||
}
|
||||
29
schema/commands/PRIVMSG.json
Normal file
29
schema/commands/PRIVMSG.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://git.eeqj.de/sneak/chat/schema/commands/PRIVMSG.json",
|
||||
"title": "PRIVMSG",
|
||||
"description": "Send a message to a channel or user. C2S: client sends to server. S2C: server relays to recipients. RFC 1459 §4.4.1.",
|
||||
"$ref": "../message.json",
|
||||
"properties": {
|
||||
"command": { "const": "PRIVMSG" },
|
||||
"from": {
|
||||
"type": "string",
|
||||
"description": "Sender nick (set by server on S2C relay)."
|
||||
},
|
||||
"to": {
|
||||
"type": "string",
|
||||
"description": "Target: #channel or nick.",
|
||||
"examples": ["#general", "alice"]
|
||||
},
|
||||
"body": {
|
||||
"type": "string",
|
||||
"description": "Message text.",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"required": ["command", "to", "body"],
|
||||
"examples": [
|
||||
{ "command": "PRIVMSG", "from": "bob", "to": "#general", "body": "hello world" },
|
||||
{ "command": "PRIVMSG", "from": "bob", "to": "alice", "body": "hey" }
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user