cli (pubsub): new signature subcommands:

A first `check` command can be used to check signature using the signature JSON data.
More commands should follow to check or sign items.

rel 381
This commit is contained in:
Goffi 2022-10-28 18:47:17 +02:00
commit 8ec64e41fd

View file

@ -1681,6 +1681,52 @@ class Reference(base.CommandBase):
self.host.quit()
class SignatureCheck(base.CommandBase):
def __init__(self, host):
super().__init__(
host,
"check",
use_output=C.OUTPUT_DICT,
use_pubsub=True,
pubsub_flags={C.SERVICE, C.NODE, C.SINGLE_ITEM},
help=_("check the validity of pubsub signature"),
)
def add_parser_options(self):
self.parser.add_argument(
"signature",
metavar="JSON",
help=_("signature data")
)
async def start(self):
try:
ret_s = await self.host.bridge.psSignatureCheck(
self.args.service,
self.args.node,
self.args.item,
self.args.signature,
self.profile,
)
except Exception as e:
self.disp(f"can't check signature: {e}", error=True)
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
else:
await self.output(data_format.deserialise((ret_s)))
self.host.quit()
class Signature(base.CommandBase):
subcommands = (
SignatureCheck,
)
def __init__(self, host):
super().__init__(
host, "signature", use_profile=False, help=_("item signature")
)
class Search(base.CommandBase):
"""This command do a search without using MAM
@ -2898,6 +2944,7 @@ class Pubsub(base.CommandBase):
Subscriptions,
Affiliations,
Reference,
Signature,
Search,
Transform,
Attachments,