refactor: structured body (array|object, never string) for canonicalization

Message bodies are always arrays of strings (text lines) or objects
(structured data like PUBKEY). Never raw strings. This enables:
- Multiline messages without escape sequences
- Deterministic JSON canonicalization (RFC 8785 JCS) for signing
- Structured data where needed

Update all schemas: body fields use array type with string items.
Update message.json envelope: body is oneOf[array, object], id is UUID.
Update README: message envelope table, examples, and canonicalization docs.
Update schema/README.md: field types, examples with array bodies.
This commit is contained in:
clawbot
2026-02-10 10:36:02 -08:00
parent dfb1636be5
commit ab70f889a6
22 changed files with 446 additions and 171 deletions

View File

@@ -2,19 +2,36 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/numerics/001.json",
"title": "001 RPL_WELCOME",
"description": "Welcome message sent after successful session creation. RFC 2812 §5.1.",
"description": "Welcome message sent after successful session creation. RFC 2812 \u00a75.1.",
"$ref": "../message.json",
"properties": {
"command": { "const": "001" },
"to": { "type": "string", "description": "Target nick." },
"command": {
"const": "001"
},
"to": {
"type": "string",
"description": "Target nick."
},
"body": {
"type": "array",
"items": { "type": "string" },
"items": {
"type": "string"
},
"description": "Welcome text lines."
}
},
"required": ["command", "to", "body"],
"required": [
"command",
"to",
"body"
],
"examples": [
{ "command": "001", "to": "alice", "body": ["Welcome to the network, alice"] }
{
"command": "001",
"to": "alice",
"body": [
"Welcome to the network, alice"
]
}
]
}

View File

@@ -2,19 +2,35 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/numerics/002.json",
"title": "002 RPL_YOURHOST",
"description": "Server host info sent after session creation. RFC 2812 §5.1.",
"description": "Server host info sent after session creation. RFC 2812 \u00a75.1.",
"$ref": "../message.json",
"properties": {
"command": { "const": "002" },
"to": { "type": "string" },
"command": {
"const": "002"
},
"to": {
"type": "string"
},
"body": {
"type": "array",
"items": { "type": "string" },
"items": {
"type": "string"
},
"description": "Host info lines."
}
},
"required": ["command", "to", "body"],
"required": [
"command",
"to",
"body"
],
"examples": [
{ "command": "002", "to": "alice", "body": ["Your host is chat.example.com, running version 0.1.0"] }
{
"command": "002",
"to": "alice",
"body": [
"Your host is chat.example.com, running version 0.1.0"
]
}
]
}

View File

@@ -2,12 +2,26 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/numerics/323.json",
"title": "323 RPL_LISTEND",
"description": "End of channel list. RFC 1459 §6.2.",
"description": "End of channel list. RFC 1459 \u00a76.2.",
"$ref": "../message.json",
"properties": {
"command": { "const": "323" },
"to": { "type": "string" },
"body": { "const": "End of /LIST" }
"command": {
"const": "323"
},
"to": {
"type": "string"
},
"body": {
"type": "array",
"items": {
"type": "string"
},
"description": "End of /LIST",
"maxItems": 1
}
},
"required": ["command", "to"]
"required": [
"command",
"to"
]
}

View File

@@ -2,17 +2,34 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/numerics/366.json",
"title": "366 RPL_ENDOFNAMES",
"description": "End of NAMES list. RFC 1459 §6.2.",
"description": "End of NAMES list. RFC 1459 \u00a76.2.",
"$ref": "../message.json",
"properties": {
"command": { "const": "366" },
"to": { "type": "string" },
"command": {
"const": "366"
},
"to": {
"type": "string"
},
"params": {
"type": "array",
"items": { "type": "string" },
"items": {
"type": "string"
},
"description": "[channel]."
},
"body": { "const": "End of /NAMES list" }
"body": {
"type": "array",
"items": {
"type": "string"
},
"description": "End of /NAMES list",
"maxItems": 1
}
},
"required": ["command", "to", "params"]
"required": [
"command",
"to",
"params"
]
}

View File

@@ -2,12 +2,26 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/numerics/376.json",
"title": "376 RPL_ENDOFMOTD",
"description": "End of MOTD. RFC 2812 §5.1.",
"description": "End of MOTD. RFC 2812 \u00a75.1.",
"$ref": "../message.json",
"properties": {
"command": { "const": "376" },
"to": { "type": "string" },
"body": { "const": "End of /MOTD command" }
"command": {
"const": "376"
},
"to": {
"type": "string"
},
"body": {
"type": "array",
"items": {
"type": "string"
},
"description": "End of /MOTD command",
"maxItems": 1
}
},
"required": ["command", "to"]
"required": [
"command",
"to"
]
}

View File

@@ -2,20 +2,46 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/numerics/401.json",
"title": "401 ERR_NOSUCHNICK",
"description": "No such nick/channel. RFC 1459 §6.1.",
"description": "No such nick/channel. RFC 1459 \u00a76.1.",
"$ref": "../message.json",
"properties": {
"command": { "const": "401" },
"to": { "type": "string" },
"command": {
"const": "401"
},
"to": {
"type": "string"
},
"params": {
"type": "array",
"items": { "type": "string" },
"items": {
"type": "string"
},
"description": "[target_nick]."
},
"body": { "const": "No such nick/channel" }
"body": {
"type": "array",
"items": {
"type": "string"
},
"description": "No such nick/channel",
"maxItems": 1
}
},
"required": ["command", "to", "params"],
"required": [
"command",
"to",
"params"
],
"examples": [
{ "command": "401", "to": "alice", "params": ["bob"], "body": "No such nick/channel" }
{
"command": "401",
"to": "alice",
"params": [
"bob"
],
"body": [
"No such nick/channel"
]
}
]
}

View File

@@ -2,20 +2,46 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/numerics/403.json",
"title": "403 ERR_NOSUCHCHANNEL",
"description": "No such channel. RFC 1459 §6.1.",
"description": "No such channel. RFC 1459 \u00a76.1.",
"$ref": "../message.json",
"properties": {
"command": { "const": "403" },
"to": { "type": "string" },
"command": {
"const": "403"
},
"to": {
"type": "string"
},
"params": {
"type": "array",
"items": { "type": "string" },
"items": {
"type": "string"
},
"description": "[channel_name]."
},
"body": { "const": "No such channel" }
"body": {
"type": "array",
"items": {
"type": "string"
},
"description": "No such channel",
"maxItems": 1
}
},
"required": ["command", "to", "params"],
"required": [
"command",
"to",
"params"
],
"examples": [
{ "command": "403", "to": "alice", "params": ["#nonexistent"], "body": "No such channel" }
{
"command": "403",
"to": "alice",
"params": [
"#nonexistent"
],
"body": [
"No such channel"
]
}
]
}

View File

@@ -2,20 +2,46 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/numerics/433.json",
"title": "433 ERR_NICKNAMEINUSE",
"description": "Nickname is already in use. RFC 1459 §6.1.",
"description": "Nickname is already in use. RFC 1459 \u00a76.1.",
"$ref": "../message.json",
"properties": {
"command": { "const": "433" },
"to": { "type": "string" },
"command": {
"const": "433"
},
"to": {
"type": "string"
},
"params": {
"type": "array",
"items": { "type": "string" },
"items": {
"type": "string"
},
"description": "[requested_nick]."
},
"body": { "const": "Nickname is already in use" }
"body": {
"type": "array",
"items": {
"type": "string"
},
"description": "Nickname is already in use",
"maxItems": 1
}
},
"required": ["command", "to", "params"],
"required": [
"command",
"to",
"params"
],
"examples": [
{ "command": "433", "to": "*", "params": ["alice"], "body": "Nickname is already in use" }
{
"command": "433",
"to": "*",
"params": [
"alice"
],
"body": [
"Nickname is already in use"
]
}
]
}

View File

@@ -2,17 +2,34 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/numerics/442.json",
"title": "442 ERR_NOTONCHANNEL",
"description": "You're not on that channel. RFC 1459 §6.1.",
"description": "You're not on that channel. RFC 1459 \u00a76.1.",
"$ref": "../message.json",
"properties": {
"command": { "const": "442" },
"to": { "type": "string" },
"command": {
"const": "442"
},
"to": {
"type": "string"
},
"params": {
"type": "array",
"items": { "type": "string" },
"items": {
"type": "string"
},
"description": "[channel]."
},
"body": { "const": "You're not on that channel" }
"body": {
"type": "array",
"items": {
"type": "string"
},
"description": "You're not on that channel",
"maxItems": 1
}
},
"required": ["command", "to", "params"]
"required": [
"command",
"to",
"params"
]
}

View File

@@ -2,17 +2,34 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://git.eeqj.de/sneak/chat/schema/numerics/482.json",
"title": "482 ERR_CHANOPRIVSNEEDED",
"description": "You're not channel operator. RFC 1459 §6.1.",
"description": "You're not channel operator. RFC 1459 \u00a76.1.",
"$ref": "../message.json",
"properties": {
"command": { "const": "482" },
"to": { "type": "string" },
"command": {
"const": "482"
},
"to": {
"type": "string"
},
"params": {
"type": "array",
"items": { "type": "string" },
"items": {
"type": "string"
},
"description": "[channel]."
},
"body": { "const": "You're not channel operator" }
"body": {
"type": "array",
"items": {
"type": "string"
},
"description": "You're not channel operator",
"maxItems": 1
}
},
"required": ["command", "to", "params"]
"required": [
"command",
"to",
"params"
]
}