From d0a65eb2008b11dcefd22800785a746d6880e794 Mon Sep 17 00:00:00 2001 From: akurbatov Date: Wed, 19 Feb 2025 11:23:55 +0300 Subject: [PATCH 1/5] VC-360 --- setup.py | 2 +- src/keri/__init__.py | 2 +- src/keri/core/scheming.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 565f98f88..789259041 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ from setuptools import find_packages, setup setup( name='keri', - version='1.1.6', # also change in src/keri/__init__.py + version='1.1.6-pr-10', # also change in src/keri/__init__.py license='Apache Software License 2.0', description='Key Event Receipt Infrastructure', long_description="KERI Decentralized Key Management Infrastructure", diff --git a/src/keri/__init__.py b/src/keri/__init__.py index d39f4a1bd..809668e01 100644 --- a/src/keri/__init__.py +++ b/src/keri/__init__.py @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -__version__ = '1.1.6' # also change in setup.py +__version__ = '1.1.6-pr-10' # also change in setup.py diff --git a/src/keri/core/scheming.py b/src/keri/core/scheming.py index 5c87667a2..9d74db6cf 100644 --- a/src/keri/core/scheming.py +++ b/src/keri/core/scheming.py @@ -15,6 +15,7 @@ from .coring import MtrDex, Serials, Saider, Saids from .. import help, kering from ..kering import ValidationError, DeserializeError +from functools import lru_cache logger = help.ogler.getLogger() @@ -192,6 +193,7 @@ def detect(raw): return True + @lru_cache(maxsize=2048) @staticmethod def verify_schema(schema): """ Validate schema integrity From 77f7404085ef3a5ab87369847d3f9bff073b674e Mon Sep 17 00:00:00 2001 From: akurbatov Date: Wed, 19 Feb 2025 11:31:22 +0300 Subject: [PATCH 2/5] VC-360 --- setup.py | 2 +- src/keri/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 789259041..0b854cf93 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ from setuptools import find_packages, setup setup( name='keri', - version='1.1.6-pr-10', # also change in src/keri/__init__.py + version='1.1.6-pr10', # also change in src/keri/__init__.py license='Apache Software License 2.0', description='Key Event Receipt Infrastructure', long_description="KERI Decentralized Key Management Infrastructure", diff --git a/src/keri/__init__.py b/src/keri/__init__.py index 809668e01..ab4e4b6df 100644 --- a/src/keri/__init__.py +++ b/src/keri/__init__.py @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -__version__ = '1.1.6-pr-10' # also change in setup.py +__version__ = '1.1.6-pr10' # also change in setup.py From a9fd0a973683979b2db715100ed1aaf01614fa2e Mon Sep 17 00:00:00 2001 From: akurbatov Date: Wed, 19 Feb 2025 11:35:23 +0300 Subject: [PATCH 3/5] VC-360 --- setup.py | 2 +- src/keri/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 0b854cf93..565f98f88 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ from setuptools import find_packages, setup setup( name='keri', - version='1.1.6-pr10', # also change in src/keri/__init__.py + version='1.1.6', # also change in src/keri/__init__.py license='Apache Software License 2.0', description='Key Event Receipt Infrastructure', long_description="KERI Decentralized Key Management Infrastructure", diff --git a/src/keri/__init__.py b/src/keri/__init__.py index ab4e4b6df..d39f4a1bd 100644 --- a/src/keri/__init__.py +++ b/src/keri/__init__.py @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -__version__ = '1.1.6-pr10' # also change in setup.py +__version__ = '1.1.6' # also change in setup.py From efeee506c2759f95e4551f5335c5733e4e9cd81c Mon Sep 17 00:00:00 2001 From: akurbatov Date: Wed, 19 Feb 2025 11:58:16 +0300 Subject: [PATCH 4/5] VC-360 --- src/keri/core/scheming.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/keri/core/scheming.py b/src/keri/core/scheming.py index 9d74db6cf..8d92a3f77 100644 --- a/src/keri/core/scheming.py +++ b/src/keri/core/scheming.py @@ -193,7 +193,6 @@ def detect(raw): return True - @lru_cache(maxsize=2048) @staticmethod def verify_schema(schema): """ Validate schema integrity @@ -204,6 +203,13 @@ def verify_schema(schema): Parameters: schema (dict): is the JSON schema to verify """ + return verify_schema_str(json.dumps(schema)) + + @lru_cache(maxsize=2048) + @staticmethod + def verify_schema_str(schema_str): + """Cached version verify_schema() since we can't cache functions with dict as parameter""" + schema = json.loads(schema_str) try: jsonschema.Draft7Validator.check_schema(schema=schema) except jsonschema.exceptions.SchemaError: From 378f2fb68c51aee78ea9924baec2327129953c02 Mon Sep 17 00:00:00 2001 From: akurbatov Date: Wed, 19 Feb 2025 12:03:05 +0300 Subject: [PATCH 5/5] VC-360 --- src/keri/core/scheming.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/keri/core/scheming.py b/src/keri/core/scheming.py index 8d92a3f77..d592659b7 100644 --- a/src/keri/core/scheming.py +++ b/src/keri/core/scheming.py @@ -193,18 +193,6 @@ def detect(raw): return True - @staticmethod - def verify_schema(schema): - """ Validate schema integrity - - Returns True if the provided schema validates successfully - as complaint Draft 7 JSON Schema False otherwise - - Parameters: - schema (dict): is the JSON schema to verify - """ - return verify_schema_str(json.dumps(schema)) - @lru_cache(maxsize=2048) @staticmethod def verify_schema_str(schema_str): @@ -217,6 +205,18 @@ def verify_schema_str(schema_str): return True + @staticmethod + def verify_schema(schema): + """ Validate schema integrity + + Returns True if the provided schema validates successfully + as complaint Draft 7 JSON Schema False otherwise + + Parameters: + schema (dict): is the JSON schema to verify + """ + return JSONSchema.verify_schema_str(json.dumps(schema)) + def verify_json(self, schema=b'', raw=b''): """ Verify the raw content against the schema for JSON that conforms to the schema