From 8f221f2e826c18d77f83010d6dfa7cb15c3ba6ca Mon Sep 17 00:00:00 2001 From: Markus Sabadello Date: Thu, 5 Oct 2023 20:06:09 +0200 Subject: [PATCH 1/2] Add functions for transforming to/from did:web document Signed-off-by: Markus Sabadello --- src/dkr/core/didding.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/dkr/core/didding.py b/src/dkr/core/didding.py index 723ffe5..b52020f 100644 --- a/src/dkr/core/didding.py +++ b/src/dkr/core/didding.py @@ -136,3 +136,15 @@ def generateDIDDoc(hby, did, aid, oobi=None, metadata=None): return resolutionResult else: return diddoc + +def toDidWeb(diddoc): + diddoc['id'] = diddoc['id'].replace('did:webs', 'did:web') + for verificationMethod in diddoc['verificationMethod']: + verificationMethod['controller'] = verificationMethod['controller'].replace('did:webs', 'did:web') + return diddoc + +def fromDidWeb(diddoc): + diddoc['id'] = diddoc['id'].replace('did:web', 'did:webs') + for verificationMethod in diddoc['verificationMethod']: + verificationMethod['controller'] = verificationMethod['controller'].replace('did:web', 'did:webs') + return diddoc From 3b7349aa6cc2e08a1d580702e763dd90d9263304 Mon Sep 17 00:00:00 2001 From: Markus Sabadello Date: Fri, 6 Oct 2023 23:42:51 +0200 Subject: [PATCH 2/2] Transform stored file to did:web Signed-off-by: Markus Sabadello --- src/dkr/app/cli/commands/did/webs/generate.py | 2 +- src/dkr/app/cli/commands/did/webs/resolve.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dkr/app/cli/commands/did/webs/generate.py b/src/dkr/app/cli/commands/did/webs/generate.py index 8654ba6..aae2027 100644 --- a/src/dkr/app/cli/commands/did/webs/generate.py +++ b/src/dkr/app/cli/commands/did/webs/generate.py @@ -87,7 +87,7 @@ def generate(self, tymth, tock=0.0, **opts): dd_file_path = os.path.join(dd_dir_path, f"{webbing.DID_JSON}") ddf = open(dd_file_path, "w") - json.dump(diddoc, ddf) + json.dump(didding.toDidWeb(diddoc), ddf) kever = self.hby.kevers[aid] diff --git a/src/dkr/app/cli/commands/did/webs/resolve.py b/src/dkr/app/cli/commands/did/webs/resolve.py index 8cecf9e..ca1b3bf 100644 --- a/src/dkr/app/cli/commands/did/webs/resolve.py +++ b/src/dkr/app/cli/commands/did/webs/resolve.py @@ -62,7 +62,7 @@ def resolve(self, tymth, tock=0.0, **opts): # Load the did doc dd_url = f"{base_url}/{webbing.DID_JSON}" print(f"Loading DID Doc from {dd_url}") - dd_actual = json.loads(self.loadUrl(dd_url).decode("utf-8")) + dd_actual = didding.fromDidWeb(json.loads(self.loadUrl(dd_url).decode("utf-8"))) # Load the KERI CESR kc_url = f"{base_url}/{webbing.KERI_CESR}"