Package: punkr
PunkrPunkr (Python Bunkr) is a python wrapper around the RPC server running within the Bunkr daemon. It requires the daemon to be running to send the Bunkr operations.InstallInstall punkr with pip:$ pip install punkrCompatible with python 3.6+Punkr classPunkrclass is the main structure to use. It can work either synchronously or asynchronously. All methods have their async replica, they can be identified by theasync_*prefix in the method names.new-text-secret       -> create a new secret whose content is a simple textnew-ssh-key           -> create a new secret whose content is an ECDSA ssh keynew-file-secret       -> dump a file content as a new secretnew-group             -> create a new groupimport-ssh-key        -> import an ssh key from a file into a secretlist-secrets          -> list all stored secretslist-devices          -> list all shared deviceslist-groups           -> list all tracked groupssend-device           -> share the current Bunkr devicereceive-device        -> import a shared Bunkr deviceremove-device         -> remove a shared device reference from Bunkrremove-local          -> untrack a secret, it does not delete the secret from the plattformrename                -> rename a secret, device or groupcreate                -> create a new empty secretwrite                 -> write a secret with new contentaccess                -> retrieve the content of a secretgrant                 -> grant capabilities to a group or device for an specified secret or grouprevoke                -> revoke a given capabilitydelete                -> erase a secret existencereceive-capability    -> import a capability for a given secretreset-triples         -> synchronize triples for a secretnoop-test             -> health check operation over a secretsecret-info           -> get secret public informationsign-ecdsa            -> make an ECDSA signature with a ECDSA Bunkr secretssh-public-data       -> retrieve a secret public datasignin                -> signin into the platfformconfirm-signin        -> confirm the signin processExamplesif__name__=="__main__":importasyncio# create a connection to the local Bunkr RPC serverpunkr=Punkr("/tmp/bunkr_daemon.sock")to_delete=[]try:# create a new text secret (synchronously)print(punkr.new_text_secret("MySuperSecret",'secret created from punkr'))to_delete.append("MySuperSecret")commands=((Command.ACCESS,["MySuperSecret"]),# This is the structure of a batch command argument(Command.ACCESS,["MySuperSecret"]),(Command.ACCESS,["MySuperSecret"]),)# create corutine to access the secret (asynchronously, order of results is not guaranteed)asyncdefasync_test():asyncforresultinpunkr.async_batch_commands(*commands):print(result)# run corutineasyncio.run(async_test())# run corutine and get the results (order of result is guaranteed, but not ordered of execution)results1=asyncio.run(punkr.async_ordered_batch_commands(*commands))print(results1)# execute a synchronous batch, ordered of execution and results ir guaranteedresults2=list(punkr.batch_commands(*commands))print(results2)assertresults1==results2# create grouppunkr.new_group("the_group")to_delete.append("the_group")# create ssh keypunkr.new_ssh_key("test_key")to_delete.append("test_key")# listingres=punkr.list_secrets()assertlen(res["content"]["secrets"])>0res=punkr.list_devices()assertlen(res["devices"])>0res=punkr.list_groups()assertlen(res["groups"])>0# renamepunkr.rename("the_group","useless_group")punkr.rename("useless_group","the_group")# create, write, access cyclecontent="some useless content"punkr.create("useless_secret",SecretType.GenericGF256)punkr.write("useless_secret",content,"text")to_delete.append("useless_secret")res=punkr.access("useless_secret")assertres["content"]==contentassertres["mode"]=="text"# grantingpunkr.grant("the_group","useless_secret")# revokepunkr.revoke("the_group","useless_secret")# reset triplespunkr.reset_triples("useless_secret")# nooppunkr.noop("useless_secret")# secret infores=punkr.secret_info("useless_secret")print(res["msg"])# ecdsa signatureres=punkr.sign_ecdsa("test_key","Zm9v")print(res["r"])print(res["s"])# ssh public datares=punkr.ssh_public_data("test_key")print(res["public_data"]["public_key"])# send deviceres=punkr.send_device("my_device")print(res["url_short"])print(res["url_raw"])exceptPunkrExceptionase:print("Error while performing a Bunkr operation:")print(e)exceptExceptionase:print(e)finally:# delete the secret (synchronously)forsinto_delete:try:punkr.delete(s)exceptPunkrExceptionase:print(f"Error deleting secret{s}:{e}")Copyright (c) [2019] [Off-the-grid-inc]