-
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.
Many additions and fixes to kli commands, new ESSR payload attachment…
… support (#803) * New mailbox commands for using bespoke mailbox services. Signed-off-by: pfeairheller <[email protected]> * Resolving merge conflicts Signed-off-by: pfeairheller <[email protected]> * Resolving merge conflicts Signed-off-by: pfeairheller <[email protected]> * Improvements to kli commands `mailbox add` and `witness authenticate` to work in all cases (like delegated AIDs). New `kli aid` command for printing the AID of an alias (useful in scripts). Added `--delpre` as a command line argument to `kli icncept` (useful in scripts). Fix for witness publisher to account for multiple events in one cue'ed message. Added support for witness auth codes for delegated AIDs. Removed logging messages in the INFO case for escrow reprocessing. Signed-off-by: pfeairheller <[email protected]> * Updated test Signed-off-by: pfeairheller <[email protected]> --------- Signed-off-by: pfeairheller <[email protected]>
- Loading branch information
1 parent
b6e4df9
commit c1163dd
Showing
29 changed files
with
736 additions
and
260 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Builder layer | ||
FROM python:3.12-alpine as builder | ||
|
||
# Install compilation dependencies | ||
RUN apk --no-cache add \ | ||
bash \ | ||
alpine-sdk \ | ||
libffi-dev \ | ||
libsodium \ | ||
libsodium-dev | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
# Setup Rust for blake3 dependency build | ||
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y |
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,58 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
KERI | ||
keri.kli.commands module | ||
""" | ||
import argparse | ||
|
||
from hio import help | ||
from hio.base import doing | ||
|
||
from keri.app.cli.common import existing | ||
from keri.kering import ConfigurationError | ||
|
||
logger = help.ogler.getLogger() | ||
|
||
parser = argparse.ArgumentParser(description='Print the AID for a given alias') | ||
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('--alias', '-a', help='human readable alias for the new identifier prefix', default=None, | ||
required=True) | ||
parser.add_argument('--passcode', '-p', help='21 character encryption passcode for keystore (is not saved)', | ||
dest="bran", default=None) # passcode => bran | ||
|
||
|
||
def handler(args): | ||
kwa = dict(args=args) | ||
return [doing.doify(status, **kwa)] | ||
|
||
|
||
def status(tymth, tock=0.0, **opts): | ||
""" Command line status handler | ||
""" | ||
_ = (yield tock) | ||
args = opts["args"] | ||
name = args.name | ||
alias = args.alias | ||
base = args.base | ||
bran = args.bran | ||
|
||
try: | ||
with existing.existingHby(name=name, base=base, bran=bran) as hby: | ||
if alias is None: | ||
alias = existing.aliasInput(hby) | ||
|
||
hab = hby.habByName(alias) | ||
if hab is None: | ||
print(f"{alias} is not a valid alias for an identifier") | ||
|
||
print(hab.pre) | ||
|
||
except ConfigurationError as e: | ||
print(f"identifier prefix for {name} does not exist, incept must be run first", ) | ||
return -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
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,135 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
KERI | ||
keri.kli.commands module | ||
""" | ||
import argparse | ||
|
||
from hio import help | ||
from hio.base import doing | ||
from hio.help import Hict | ||
|
||
from keri import kering | ||
from keri.app import connecting, habbing, forwarding | ||
from keri.app.agenting import httpClient, WitnessPublisher | ||
from keri.app.cli.common import existing | ||
from keri.core import serdering | ||
|
||
logger = help.ogler.getLogger() | ||
|
||
parser = argparse.ArgumentParser(description='Add mailbox role') | ||
parser.set_defaults(handler=lambda args: add(args), | ||
transferable=True) | ||
parser.add_argument('--name', '-n', help='keystore name and file location of KERI keystore', required=True) | ||
parser.add_argument('--alias', '-a', help='human readable alias for the identifier to whom the credential was issued', | ||
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='22 character encryption passcode for keystore (is not saved)', | ||
dest="bran", default=None) # passcode => bran | ||
parser.add_argument("--mailbox", '-w', help="the mailbox AID or alias to add", required=True) | ||
|
||
|
||
def add(args): | ||
""" Command line handler for adding an aid to a watcher's list of AIds to watch | ||
Parameters: | ||
args(Namespace): parsed command line arguments | ||
""" | ||
|
||
ed = AddDoer(name=args.name, | ||
alias=args.alias, | ||
base=args.base, | ||
bran=args.bran, | ||
mailbox=args.mailbox) | ||
return [ed] | ||
|
||
|
||
class AddDoer(doing.DoDoer): | ||
|
||
def __init__(self, name, alias, base, bran, mailbox): | ||
self.hby = existing.setupHby(name=name, base=base, bran=bran) | ||
self.hab = self.hby.habByName(alias) | ||
self.org = connecting.Organizer(hby=self.hby) | ||
self.witpub = WitnessPublisher(hby=self.hby) | ||
|
||
if mailbox in self.hby.kevers: | ||
mbx = mailbox | ||
else: | ||
mbx = self.org.find("alias", mailbox) | ||
if len(mbx) != 1: | ||
raise ValueError(f"invalid mailbox {mailbox}") | ||
mbx = mbx[0]['id'] | ||
|
||
if not mbx: | ||
raise ValueError(f"unknown mailbox {mailbox}") | ||
|
||
self.mailbox = mbx | ||
|
||
doers = [doing.doify(self.addDo), self.witpub] | ||
|
||
super(AddDoer, self).__init__(doers=doers) | ||
|
||
def addDo(self, tymth, tock=0.0): | ||
""" Grant credential by creating /ipex/grant exn message | ||
Parameters: | ||
tymth (function): injected function wrapper closure returned by .tymen() of | ||
Tymist instance. Calling tymth() returns associated Tymist .tyme. | ||
tock (float): injected initial tock value | ||
Returns: doifiable Doist compatible generator method | ||
""" | ||
# enter context | ||
self.wind(tymth) | ||
self.tock = tock | ||
_ = (yield self.tock) | ||
|
||
if isinstance(self.hab, habbing.GroupHab): | ||
raise ValueError("watchers for multisig AIDs not currently supported") | ||
|
||
kel = self.hab.replay() | ||
data = dict(cid=self.hab.pre, | ||
role=kering.Roles.mailbox, | ||
eid=self.mailbox) | ||
|
||
route = "/end/role/add" | ||
msg = self.hab.reply(route=route, data=data) | ||
self.hab.psr.parseOne(ims=(bytes(msg))) # make copy to preserve | ||
|
||
fargs = dict([("kel", kel.decode("utf-8")), | ||
("rpy", msg.decode("utf-8"))]) | ||
|
||
headers = (Hict([ | ||
("Content-Type", "multipart/form-data"), | ||
])) | ||
|
||
client, clientDoer = httpClient(self.hab, self.mailbox) | ||
self.extend([clientDoer]) | ||
|
||
client.request( | ||
method="POST", | ||
path=f"{client.requester.path}/mailboxes", | ||
headers=headers, | ||
fargs=fargs | ||
) | ||
while not client.responses: | ||
yield self.tock | ||
|
||
rep = client.respond() | ||
if rep.status == 200: | ||
msg = self.hab.replyEndRole(cid=self.hab.pre, role=kering.Roles.mailbox) | ||
self.witpub.msgs.append(dict(pre=self.hab.pre, msg=bytes(msg))) | ||
|
||
while not self.witpub.cues: | ||
yield self.tock | ||
|
||
print(f"Mailbox {self.mailbox} added for {self.hab.name}") | ||
|
||
else: | ||
print(rep.status, rep.data) | ||
|
||
self.remove([clientDoer, self.witpub]) |
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
Oops, something went wrong.