Skip to content

Commit

Permalink
Merge pull request #20 from peacekeeper/to-from-did-web
Browse files Browse the repository at this point in the history
Transform to/from did:web document
  • Loading branch information
2byrds authored Oct 6, 2023
2 parents a06dc52 + 3b7349a commit d3d5b84
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/dkr/app/cli/commands/did/webs/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion src/dkr/app/cli/commands/did/webs/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
12 changes: 12 additions & 0 deletions src/dkr/core/didding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d3d5b84

Please sign in to comment.