-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: de-couple contact creation from OOBI resolution (#882)
- Loading branch information
Showing
6 changed files
with
93 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
KERI | ||
keri.kli.commands.contacts module | ||
""" | ||
import argparse | ||
import sys | ||
|
||
from hio import help | ||
from hio.base import doing | ||
|
||
from keri.app import connecting | ||
from keri.app.cli.common import existing | ||
from keri.kering import ConfigurationError | ||
|
||
logger = help.ogler.getLogger() | ||
|
||
# Could be expanded to provide arbitrary data if desired | ||
parser = argparse.ArgumentParser(description='Replace contact information for identifier prefix with alias information') | ||
parser.set_defaults(handler=lambda args: handler(args), | ||
transferable=True) | ||
parser.add_argument('--name', '-n', help='keystore name and file location of KERI keystore', required=True) | ||
parser.add_argument('--base', '-b', help='additional optional prefix to file location of KERI keystore', | ||
required=False, default="") | ||
parser.add_argument('--passcode', '-p', help='21 character encryption passcode for keystore (is not saved)', | ||
dest="bran", default=None) # passcode => bran | ||
parser.add_argument('--prefix', '-o', help='identifier prefix to replace contact information for', required=True) | ||
parser.add_argument('--alias', '-a', help='human readable alias for the contact', required=True) | ||
|
||
|
||
def handler(args): | ||
kwa = dict(args=args) | ||
return [doing.doify(replace, **kwa)] | ||
|
||
|
||
def replace(tymth, tock=0.0, **opts): | ||
""" Command line status handler | ||
""" | ||
_ = (yield tock) | ||
args = opts["args"] | ||
name = args.name | ||
base = args.base | ||
bran = args.bran | ||
prefix = args.prefix | ||
alias = args.alias | ||
|
||
try: | ||
with existing.existingHby(name=name, base=base, bran=bran) as hby: | ||
org = connecting.Organizer(hby=hby) | ||
|
||
if prefix not in hby.kevers: | ||
print(f"{prefix} is not a known identifier, oobi must be resolved first") | ||
sys.exit(-1) | ||
|
||
org.replace(pre=prefix, data=dict(alias=alias)) | ||
|
||
except ConfigurationError: | ||
print(f"identifier prefix for {name} does not exist, incept must be run first") | ||
sys.exit(-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters