diff --git a/Makefile b/Makefile index ccafde9c..35c5500f 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.2.0-dev0 . + @docker buildx build --platform=linux/amd64 --no-cache -f images/keria.dockerfile --tag weboftrust/keria:0.2.0-dev1 . publish-keria: @docker push weboftrust/keria --all-tags \ No newline at end of file diff --git a/setup.py b/setup.py index c2732386..0ce9edff 100644 --- a/setup.py +++ b/setup.py @@ -76,7 +76,7 @@ python_requires='>=3.12.2', install_requires=[ 'hio>=0.6.12', - 'keri==1.2.0-dev2', + 'keri==1.2.0-dev4', 'mnemonic>=0.20', 'multicommand>=1.0.0', 'falcon>=3.1.3', diff --git a/src/keria/app/agenting.py b/src/keria/app/agenting.py index 12f2d57f..caae9c3f 100644 --- a/src/keria/app/agenting.py +++ b/src/keria/app/agenting.py @@ -9,7 +9,6 @@ from dataclasses import asdict from urllib.parse import urlparse, urljoin - import falcon from falcon import media from hio.base import doing @@ -21,7 +20,6 @@ from keri.app.notifying import Notifier from keri.app.storing import Mailboxer - from keri.app import configing, keeping, habbing, storing, signaling, oobiing, agenting, \ forwarding, querying, connecting, grouping from keri.app.grouping import Counselor @@ -29,7 +27,6 @@ from keri.core import coring, parsing, eventing, routing, serdering from keri.core.coring import Ilks from keri.core.signing import Salter -from keri.db import dbing from keri.db.basing import OobiRecord from keri.vc import protocoling @@ -211,8 +208,8 @@ def create(self, caid, salt=None): configDir=self.configDir, configFile=self.configFile) - res = self.adb.agnt.pin(keys=(caid,), - val=coring.Prefixer(qb64=agent.pre)) + self.adb.agnt.pin(keys=(caid,), + val=coring.Prefixer(qb64=agent.pre)) self.adb.ctrl.pin(keys=(agent.pre,), val=coring.Prefixer(qb64=caid)) @@ -362,7 +359,8 @@ def __init__(self, hby, rgy, agentHab, agency, caid, **opts): tvy=self.tvy, exc=self.exc, rvy=self.rvy, - vry=self.verifier) + vry=self.verifier, + local=True) # disable misfit escrow until we can add another parser for remote. doers.extend([ Initer(agentHab=agentHab, caid=caid), @@ -373,7 +371,7 @@ def __init__(self, hby, rgy, agentHab, agency, caid, **opts): Witnesser(receiptor=receiptor, witners=self.witners), Delegator(agentHab=agentHab, swain=self.swain, anchors=self.anchors), ExchangeSender(hby=hby, agentHab=agentHab, exc=self.exc, exchanges=self.exchanges), - Granter(hby=hby, rgy=rgy, agentHab=agentHab, exc=self.exc, grants=self.grants), + Granter(hby=hby, rgy=rgy, agentHab=agentHab, exc=self.exc, grants=self.grants), Admitter(hby=hby, witq=self.witq, psr=self.parser, agentHab=agentHab, exc=self.exc, admits=self.admits), GroupRequester(hby=hby, agentHab=agentHab, counselor=self.counselor, groups=self.groups), SeekerDoer(seeker=self.seeker, cues=self.verifier.cues), @@ -752,6 +750,7 @@ def __init__(self, kvy, rgy, rvy, tvy, exc, vry, registrar, credentialer): def recur(self, tyme): """ Process all escrows once per loop. """ self.kvy.processEscrows() + self.kvy.processEscrowDelegables() self.rgy.processEscrows() self.rvy.processEscrowReply() if self.tvy is not None: diff --git a/src/keria/app/delegating.py b/src/keria/app/delegating.py index 45f080ed..8bd5bf74 100644 --- a/src/keria/app/delegating.py +++ b/src/keria/app/delegating.py @@ -39,6 +39,9 @@ def delegation(self, pre, sn=None, proxy=None): if pre not in self.hby.habs: raise kering.ValidationError(f"{pre} is not a valid local AID for delegation") + if proxy is not None: + self.proxy = proxy + # load the hab of the delegated identifier to anchor hab = self.hby.habs[pre] delpre = hab.kever.delpre # get the delegator identifier @@ -50,22 +53,9 @@ def delegation(self, pre, sn=None, proxy=None): # load the event and signatures evt = hab.makeOwnEvent(sn=sn) - if isinstance(hab, habbing.GroupHab): - phab = hab.mhab - elif hab.kever.sn > 0: - phab = hab - elif proxy is not None: - phab = proxy - elif self.proxy is not None: - phab = self.proxy - else: - raise kering.ValidationError("no proxy to send messages for delegation") - srdr = serdering.SerderKERI(raw=evt) - del evt[:srdr.size] - self.postman.send(hab=phab, dest=delpre, topic="delegate", serder=srdr, attachment=evt) - - self.hby.db.dune.pin(keys=(srdr.pre, srdr.said), val=srdr) + self.witDoer.msgs.append(dict(pre=pre, sn=srdr.sn)) + self.hby.db.dpwe.pin(keys=(srdr.pre, srdr.said), val=srdr) def complete(self, prefixer, seqner, saider=None): """ Check for completed delegation protocol for the specific event @@ -114,8 +104,8 @@ def escrowDo(self, tymth, tock=1.0): yield 0.5 def processEscrows(self): - self.processUnanchoredEscrow() self.processPartialWitnessEscrow() + self.processUnanchoredEscrow() def processUnanchoredEscrow(self): """ @@ -134,11 +124,10 @@ def processUnanchoredEscrow(self): couple = seqner.qb64b + dserder.saidb dgkey = dbing.dgKey(kever.prefixer.qb64b, kever.serder.saidb) self.hby.db.setAes(dgkey, couple) # authorizer event seal (delegator/issuer) - self.witDoer.msgs.append(dict(pre=pre, sn=serder.sn)) # Move to escrow waiting for witness receipts - print(f"Waiting for fully signed witness receipts for {serder.sn}") - self.hby.db.dpwe.pin(keys=(pre, said), val=serder) + print(f"Delegation approval received, {serder.pre} confirmed") + self.hby.db.cdel.put(keys=(pre, coring.Seqner(sn=serder.sn).qb64), val=coring.Saider(qb64=serder.said)) self.hby.db.dune.rem(keys=(pre, said)) def processPartialWitnessEscrow(self): @@ -149,7 +138,9 @@ def processPartialWitnessEscrow(self): """ for (pre, said), serder in self.hby.db.dpwe.getItemIter(): # group partial witness escrow + hab = self.hby.habs[pre] kever = self.hby.kevers[pre] + delpre = hab.kever.delpre # get the delegator identifier dgkey = dbing.dgKey(pre, serder.said) seqner = coring.Seqner(sn=serder.sn) @@ -163,6 +154,22 @@ def processPartialWitnessEscrow(self): witnessed = True if not witnessed: continue - print(f"Witness receipts complete, {pre} confirmed.") + print(f"Witness receipts complete, waiting for delegation approval.") + if isinstance(hab, habbing.GroupHab): + phab = hab.mhab + elif hab.kever.sn > 0: + phab = hab + elif self.proxy is not None: + phab = self.proxy + else: + raise kering.ValidationError("no proxy to send messages for delegation") + + evt = hab.db.cloneEvtMsg(pre=serder.pre, fn=0, dig=serder.said) + + srdr = serdering.SerderKERI(raw=evt) + del evt[:srdr.size] + self.postman.send(hab=phab, dest=delpre, topic="delegate", serder=srdr, attachment=evt) + self.hby.db.dpwe.rem(keys=(pre, said)) - self.hby.db.cdel.put(keys=(pre, seqner.qb64), val=coring.Saider(qb64=serder.said)) + self.hby.db.dune.pin(keys=(srdr.pre, srdr.said), val=srdr) + diff --git a/tests/app/test_delegating.py b/tests/app/test_delegating.py index 01d4fb54..bf353869 100644 --- a/tests/app/test_delegating.py +++ b/tests/app/test_delegating.py @@ -32,10 +32,6 @@ def test_sealer(): with pytest.raises(kering.ValidationError): anchorer.delegation(pre="EHgwVwQT15OJvilVvW57HE4w0-GPs_Stj2OFoAHZSysY") - # Needs a proxy - with pytest.raises(kering.ValidationError): - anchorer.delegation(pre=delegate.pre) - # Run delegation to escrow inception event anchorer.delegation(pre=delegate.pre, proxy=proxy) doist.recur(deeds=deeds)