comparison sat_frontends/jp/cmd_pubsub.py @ 3959:da0e772881c3

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
author Goffi <goffi@goffi.org>
date Fri, 28 Oct 2022 18:47:17 +0200
parents 08c1d5485411
children 0f858aa0b92c
comparison
equal deleted inserted replaced
3958:e2a5f2f5e57b 3959:da0e772881c3
1677 except Exception as e: 1677 except Exception as e:
1678 self.disp(f"can't send reference: {e}", error=True) 1678 self.disp(f"can't send reference: {e}", error=True)
1679 self.host.quit(C.EXIT_BRIDGE_ERRBACK) 1679 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
1680 else: 1680 else:
1681 self.host.quit() 1681 self.host.quit()
1682
1683
1684 class SignatureCheck(base.CommandBase):
1685 def __init__(self, host):
1686 super().__init__(
1687 host,
1688 "check",
1689 use_output=C.OUTPUT_DICT,
1690 use_pubsub=True,
1691 pubsub_flags={C.SERVICE, C.NODE, C.SINGLE_ITEM},
1692 help=_("check the validity of pubsub signature"),
1693 )
1694
1695 def add_parser_options(self):
1696 self.parser.add_argument(
1697 "signature",
1698 metavar="JSON",
1699 help=_("signature data")
1700 )
1701
1702 async def start(self):
1703 try:
1704 ret_s = await self.host.bridge.psSignatureCheck(
1705 self.args.service,
1706 self.args.node,
1707 self.args.item,
1708 self.args.signature,
1709 self.profile,
1710 )
1711 except Exception as e:
1712 self.disp(f"can't check signature: {e}", error=True)
1713 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
1714 else:
1715 await self.output(data_format.deserialise((ret_s)))
1716 self.host.quit()
1717
1718
1719 class Signature(base.CommandBase):
1720 subcommands = (
1721 SignatureCheck,
1722 )
1723
1724 def __init__(self, host):
1725 super().__init__(
1726 host, "signature", use_profile=False, help=_("item signature")
1727 )
1682 1728
1683 1729
1684 class Search(base.CommandBase): 1730 class Search(base.CommandBase):
1685 """This command do a search without using MAM 1731 """This command do a search without using MAM
1686 1732
2896 Subscribe, 2942 Subscribe,
2897 Unsubscribe, 2943 Unsubscribe,
2898 Subscriptions, 2944 Subscriptions,
2899 Affiliations, 2945 Affiliations,
2900 Reference, 2946 Reference,
2947 Signature,
2901 Search, 2948 Search,
2902 Transform, 2949 Transform,
2903 Attachments, 2950 Attachments,
2904 Secret, 2951 Secret,
2905 Hook, 2952 Hook,