From 290bac9aeb02a1a7f6e6daece32754416419b184 Mon Sep 17 00:00:00 2001 From: Philip Feairheller Date: Fri, 8 Mar 2024 10:03:31 -0800 Subject: [PATCH] New endpoint for renaming credential registries. Includes support to join an existing registry. (#209) * New endpoint for renaming credential registries. Includes support to join an existing registry. Signed-off-by: pfeairheller * Version bump Signed-off-by: pfeairheller --------- Signed-off-by: pfeairheller --- Makefile | 2 +- setup.py | 4 +-- src/keria/__init__.py | 2 +- src/keria/app/credentialing.py | 65 ++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b456a129..307699ed 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: build-keria build-keria: - @docker buildx build --platform=linux/amd64 --no-cache -f images/keria.dockerfile --tag weboftrust/keria:0.1.2 --tag weboftrust/keria:latest . + @docker buildx build --platform=linux/amd64 --no-cache -f images/keria.dockerfile --tag weboftrust/keria:0.1.3 --tag weboftrust/keria:latest . publish-keria: @docker push weboftrust/keria --all-tags \ No newline at end of file diff --git a/setup.py b/setup.py index 97e95bf0..62b62a11 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ setup( name='keria', - version='0.1.2', # also change in src/keria/__init__.py + version='0.1.3', # also change in src/keria/__init__.py license='Apache Software License 2.0', description='KERIA: KERI Agent in the cloud', long_description="KERIA: KERI Agent in the cloud.", @@ -76,7 +76,7 @@ python_requires='>=3.10.4', install_requires=[ 'hio>=0.6.9', - 'keri>=1.1.1', + 'keri>=1.1.6', 'mnemonic>=0.20', 'multicommand>=1.0.0', 'falcon>=3.1.0', diff --git a/src/keria/__init__.py b/src/keria/__init__.py index 761e25ca..7657da7f 100644 --- a/src/keria/__init__.py +++ b/src/keria/__init__.py @@ -3,5 +3,5 @@ main package """ -__version__ = '0.1.2' # also change in setup.py +__version__ = '0.1.3' # also change in setup.py diff --git a/src/keria/app/credentialing.py b/src/keria/app/credentialing.py index 8e75f295..70185c9a 100644 --- a/src/keria/app/credentialing.py +++ b/src/keria/app/credentialing.py @@ -14,6 +14,8 @@ from keri.app.habbing import SignifyGroupHab from keri.core import coring, scheming, serdering from keri.db import dbing +from keri.db.dbing import dgKey +from keri.vdr import viring from keria.core import httping, longrunning @@ -230,6 +232,69 @@ def on_get(req, rep, name, registryName): rep.content_type = "application/json" rep.data = json.dumps(rd).encode("utf-8") + @staticmethod + def on_put(req, rep, name, registryName): + """ Registry Resource PUT endpoint + + Parameters: + req: falcon.Request HTTP request + rep: falcon.Response HTTP response + name (str): human readable name for AID + registryName(str): human readable name for registry or its SAID + + --- + summary: Get a single credential issuance and revocation registy + description: Get a single credential issuance and revocation registy + tags: + - Registries + responses: + 200: + description: credential issuance and revocation registy + + """ + agent = req.context.agent + + hab = agent.hby.habByName(name) + if hab is None: + raise falcon.HTTPNotFound(description=f"{name} is not a valid reference to an identifier") + + body = req.get_media() + if 'name' not in body: + raise falcon.HTTPBadRequest(description="'name' is required in body") + + name = body['name'] + if agent.rgy.registryByName(name) is not None: + raise falcon.HTTPBadRequest(description=f"{name} is already in use for a registry") + + registry = agent.rgy.registryByName(registryName) + if registry is None: + if registryName in agent.rgy.regs: # Check to see if the registryName parameter is a SAID + registry = agent.rgy.regs[registryName] + else: + regk = registryName + key = dgKey(regk, regk) + raw = agent.rgy.reger.getTvt(key=key) + if raw is None: + raise falcon.HTTPNotFound( + description=f"{registryName} is not a valid reference to a credential registry") + + regser = serdering.SerderKERI(raw=bytes(raw)) + registry = agent.rgy.makeSignifyRegistry(name, hab.pre, regser) + + regord = viring.RegistryRecord(registryKey=registry.regk, prefix=hab.pre) + agent.rgy.reger.regs.pin(keys=(name,), val=regord) + registry.name = name + + rd = dict( + name=registry.name, + regk=registry.regk, + pre=registry.hab.pre, + state=asdict(registry.tever.state()) + ) + rep.status = falcon.HTTP_200 + rep.content_type = "application/json" + rep.data = json.dumps(rd).encode("utf-8") + class SchemaResourceEnd: