Spec SAS verification and the common key verification framework

Reference implementations:
* 94f664e725
* https://github.com/matrix-org/matrix-react-sdk/pull/2461
* https://github.com/matrix-org/matrix-js-sdk/pull/818
* https://github.com/matrix-org/matrix-react-sdk/pull/2596
* https://github.com/matrix-org/matrix-js-sdk/pull/837

Proposals:
* [MSC1717](https://github.com/matrix-org/matrix-doc/pull/1717)
* [MSC1267](https://github.com/matrix-org/matrix-doc/issues/1267)

No alterations to either proposal have been made intentionally here.
This commit is contained in:
Travis Ralston 2019-06-04 12:41:30 -06:00
parent 9cb60fa468
commit a3364ff357
20 changed files with 847 additions and 3 deletions

View file

@ -18,6 +18,7 @@ import inspect
import json
import os
import logging
import re
logger = logging.getLogger(__name__)
@ -225,3 +226,19 @@ class MatrixSections(Sections):
examples=swagger_def['examples'],
title_kind=subtitle_title_char)
return rendered
def render_sas_emoji_table(self):
emoji = self.units.get("sas_emoji")
rendered = ".. csv-table::\n"
rendered += " :header: \"Number\", \"Emoji\", \"Unicode\", \"Description\"\n"
rendered += " :widths: 10, 10, 15, 20\n"
rendered += "\n"
for row in emoji:
rendered += " %d, \"%s\", \"``%s``\", \"%s\"\n" % (
row['number'],
row['emoji'],
row['unicode'],
row['description'],
)
rendered += "\n"
return rendered

View file

@ -59,6 +59,8 @@ TARGETS = os.path.join(matrix_doc_dir, "specification/targets.yaml")
ROOM_EVENT = "core-event-schema/room_event.yaml"
STATE_EVENT = "core-event-schema/state_event.yaml"
SAS_EMOJI_JSON = os.path.join(matrix_doc_dir, "data-definitions/sas-emoji.json")
logger = logging.getLogger(__name__)
# a yaml Loader which loads mappings into OrderedDicts instead of regular
@ -1088,3 +1090,21 @@ class MatrixUnits(Units):
"string": git_version,
"revision": git_commit
}
def load_sas_emoji(self):
with open(SAS_EMOJI_JSON, 'r', encoding='utf-8') as sas_json:
emoji = json.load(sas_json)
# Verify the emoji matches the unicode
for c in emoji:
e = c['emoji']
logger.info("Checking emoji %s (%s)", e, c['description'])
u = re.sub(r'U\+([0-9a-fA-F]+)', lambda m: chr(int(m.group(1), 16)), c['unicode'])
if e != u:
raise Exception("Emoji %s should be %s not %s" % (
c['description'],
repr(e),
c['unicode'],
))
return emoji